Fundamental Programming MCQs

100 MCQs  (Page 10 of 10)

Which description best defines encapsulation?
Bundling data with the methods that operate on it and restricting direct access to the internal state
Deriving new classes from existing ones
Giving one interface multiple implementations
Hiding implementation complexity by exposing only essential features
In Visual Basic, code runs in response to user actions such as button clicks. Which paradigm is this?
Functional programming
Procedural batch programming
Logic programming
Event-driven programming
According to the structured program theorem (Böhm–Jacopini), which three control structures are sufficient for any algorithm?
Sequence, selection, iteration
Selection, recursion, exceptions
Iteration, inheritance, selection
Sequence, goto, recursion
What best describes Python's type system?
Dynamically and weakly typed
Dynamically and strongly typed
Statically and weakly typed
Statically and strongly typed
In a C++ try block that can throw a Derived exception (where Derived inherits from Base), what is the correct order of catch blocks?
catch(Derived&) before catch(Base&), with catch(...) last
catch(...) first
catch(Base&) before catch(Derived&)
Order does not matter
When does the else block of a Python try/except/else statement run?
Only when finally is absent
Always
Only when the try block raised no exception
Only when an exception occurred
In C++, what happens when int a[5]; a[7] = 3; is executed?
The array automatically grows
Compilation error
std::out_of_range is thrown
Undefined behavior; there is no compile-time or runtime bounds check