Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q11: What is the purpose of the function onkeypress() in the refactored code?
- A: To read from a file
- B: To check if a key is pressed
- C: To print a character and return if it is 'x'
- D: To process file changes
View Answer
C
Q12: In the refactored code, what is the function onfilechanged() responsible for?
- A: Monitoring keyboard input
- B: Writing to a file
- C: Checking if the file has changed and reacting accordingly
- D: Sending network requests
View Answer
C
Q13: In the second example, what does the condition if (f.good() && a != f.peek()) check?
- A: If the file is writeable
- B: If the file exists and has content different from 'a'
- C: If the file is empty
- D: If the file is closed
View Answer
B
Q14: What happens when either 'x' is encountered in the file or keyboard input in the second example?
- A: The loop continues
- B: The loop terminates
- C: The file is deleted
- D: The program crashes
View Answer
B
Q15: Why were the two basic examples shown in the lecture?
- A: They demonstrate advanced concepts
- B: They are difficult to write
- C: They are simple and introduce event-driven concepts
- D: They highlight file I/O operations
View Answer
C
Q16: What key concept will be introduced at the end of the course?
- A: Multi-threading
- B: Event-driven programming on mobiles
- C: Network security
- D: Database management
View Answer
B
Q17: What is a common issue left unaddressed in the second code example?
- A: Infinite loop
- B: Memory leak
- C: Busy wait
- D: Syntax error
View Answer
C
Q18: What is the purpose of the onkeypress() function in the code example?
- A: To check if the keyboard is pressed.
- B: To read a character from the keyboard and return whether it is 'x'.
- C: To read a character from a file.
- D: To process file changes.
View Answer
B
Q19: What does the onfilechanged() function do in the code example?
- A: It monitors keyboard input.
- B: It checks if the file has changed.
- C: It reads a character from a file and returns whether it is 'x'.
- D: It writes a character to a file.
View Answer
C
Q20: In the main loop of the code example, what causes the program to exit?
- A: When 'x' is read from the keyboard or from the file.
- B: When any character is read from the keyboard or the file.
- C: When the file is empty.
- D: When the keyboard is not pressed.
View Answer
A