0% found this document useful (0 votes)
7 views15 pages

OOP Chapter One

The document consists of multiple-choice questions and answers related to Object-Oriented Programming (OOP) concepts, including programming paradigms, features of OOP, and specific programming languages like Java. Each question is followed by the correct answer and an explanation referencing the chapter content for clarity. The content covers various aspects such as encapsulation, inheritance, polymorphism, and the benefits of OOP.

Uploaded by

eliasaraya142
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views15 pages

OOP Chapter One

The document consists of multiple-choice questions and answers related to Object-Oriented Programming (OOP) concepts, including programming paradigms, features of OOP, and specific programming languages like Java. Each question is followed by the correct answer and an explanation referencing the chapter content for clarity. The content covers various aspects such as encapsulation, inheritance, polymorphism, and the benefits of OOP.

Uploaded by

eliasaraya142
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Chapter 1: Introduction to Object-Oriented Programming

Multiple Choice Fragen


Instructions: Choose the best answer for each question. Each question has four options, with
only one correct answer. Detailed explanations follow each question, referencing chapter con-
tent to aid understanding.
Compilation Note: Compile using PDFLaTeX in Overleaf or latexmk. The ‘‘ command en-
sures explanations appear. If solutions are missing, verify the ‘exam‘ class is supported and ‘‘
is not overridden.
1. What is a programming paradigm, as defined in Chapter 1?
A. A specific programming language.
B. A style of organizing computer programs.
C. A hardware platform.
D. A debugging tool.

Solution: Correct Answer: B


Explanation: Page 1 defines a programming paradigm as a style or way of program-
ming that shapes program design and organization. For example, OOP uses objects,
while procedural programming uses functions. A is incorrect, as languages (e.g., Java)
implement paradigms. C is wrong, as hardware supports execution, not program struc-
ture. D refers to tools like debuggers, not paradigms.

2. Which paradigm uses explicit sequences of commands?


A. Declarative
B. Imperative
C. Functional
D. Event-Driven

Solution: Correct Answer: B


Explanation: Page 1 states that imperative programming uses an explicit sequence of
commands to control flow, e.g., loops in C. Declarative (A) specifies results without
steps (e.g., SQL). Functional (C) uses function calls avoiding state. Event-driven (D)
responds to user actions, not sequential commands.

3. What characterizes declarative programming?


A. Specifying how to achieve results.
B. Stating the desired result without how.
C. Using objects to model data.
D. Relying on user events.
Solution: Correct Answer: B
Explanation: Page 1 explains declarative programming state[s] the result you want,
not how to get it, e.g., SQL queries. A is imperative programming. C describes OOP.
D refers to event-driven programming, which uses events like clicks.

4. Which paradigm avoids global state?


A. Procedural
B. Object-Oriented
C. Functional
D. Imperative

Solution: Correct Answer: C


Explanation: Page 1 notes functional programming uses (nested) function calls that
avoid any global state, e.g., pure functions in Haskell. Procedural (A) and imperative
(D) often use global data, vulnerable to changes. OOP (B) encapsulates state within
objects, not globally.

5. What is a feature of event-driven programming?


A. Sequential command execution.
B. Response to asynchronous actions.
C. No use of functions.
D. Global data access.

Solution: Correct Answer: B


Explanation: Page 4 describes event-driven programming as flow determined by asyn-
chronous actions like mouse clicks, e.g., Visual Basic button handlers. A is procedural.
C is false, as functions handle events. D is a procedural drawback, not event-driven.

6. Which paradigm uses procedure calls?


A. Declarative
B. Procedural
C. Functional
D. Logic

Solution: Correct Answer: B


Explanation: Page 1 defines procedural programming as imperative programming
with procedure calls, e.g., functions in C. Declarative (A) avoids procedural steps.
Functional (C) uses functions but avoids state. Logic (D) uses rules and facts.

Page 2
7. What does structured programming emphasize?
A. Global data sharing.
B. Nested control structures.
C. Asynchronous events.
D. Function nesting.

Solution: Correct Answer: B


Explanation: Page 1 states structured programming uses clean, go to-free, nested
control structures, e.g., loops and conditionals in Pascal. A is a procedural flaw. C is
event-driven. D is functional programmings focus.

8. Which paradigm uses message passing between objects?


A. Imperative
B. Object-Oriented
C. Declarative
D. Procedural

Solution: Correct Answer: B


Explanation: Page 1 notes OOP involves sending messages to objects, expanded on
Page 9 as objects communicating via method calls, e.g., a customer requesting an ac-
count balance. A, C, and D dont use objects or message passing.

9. What is a drawback of procedural programming?


A. Data hiding.
B. Global data vulnerability.
C. Object communication.
D. Event-driven control.

Solution: Correct Answer: B


Explanation: Page 2 highlights that procedural programmings global data is vulnera-
ble to an inadvertent change, e.g., a function altering shared variables in C. Data hiding
(A) is an OOP feature. C and D are unrelated to procedural flaws.

10. Which paradigm uses facts and rules for computation?


A. Logic
B. Functional
C. Procedural
D. Object-Oriented

Page 3
Solution: Correct Answer: A
Explanation: Page 2 defines logic programming as specifying a set of facts and rules
for inference, e.g., Prolog. Functional (B) uses function calls, procedural (C) uses
commands, and OOP (D) uses objects.

11. What is a characteristic of flow-driven programming?


A. Single process execution.
B. Multiple processes over channels.
C. No data sharing.
D. Object-based design.

Solution: Correct Answer: B


Explanation: Page 2 describes flow-driven programming as multiple processes com-
municating over predefined channels, e.g., concurrent systems. A is sequential pro-
gramming. C is functional. D is OOP.

12. Which paradigm is best for real-world modeling?


A. Procedural
B. Object-Oriented
C. Declarative
D. Functional

Solution: Correct Answer: B


Explanation: Page 3 notes OOP models real world problems by tying data to functions
in objects, e.g., a bank account object. Procedural (A) focuses on actions, declarative
(C) on results, and functional (D) avoids state.

13. What does function-level programming avoid?


A. Functions
B. Variables
C. Objects
D. Events

Solution: Correct Answer: B


Explanation: Page 1 states function-level programming have no variables, using com-
binators instead. Functions (A) are central, objects (C) are OOP, and events (D) are
event-driven.

14. Which paradigm is Visual Basic designed for?

Page 4
A. Functional
B. Procedural
C. Event-Driven
D. Declarative

Solution: Correct Answer: C


Explanation: Page 5 notes Visual Basic is specifically designed to facilitate event-
driven programming, e.g., handling button clicks. Functional (A), procedural (B), and
declarative (D) are not its primary focus.

15. What is a key feature of procedural programming?


A. Data hiding.
B. Hierarchical decomposition.
C. Asynchronous control.
D. No functions.

Solution: Correct Answer: B


Explanation: Page 2 explains procedural programming uses hierarchical decompo-
sition to break tasks into functions, e.g., flowcharts in C. Data hiding (A) is OOP,
asynchronous control (C) is event-driven, and functions (D) are central to procedural.

16. What is an object in OOP?


A. A programming language.
B. A runtime entity with data and behavior.
C. A compilation tool.
D. A global variable.

Solution: Correct Answer: B


Explanation: Page 6 defines objects as basic run time entities with data and code, e.g.,
a bank account with balance and methods. A is a tool like Java, C is a compiler, and D
is a procedural concept.

17. What is a class in OOP?


A. A collection of objects with similar properties.
B. A single object instance.
C. A procedure call.
D. A global data structure.

Page 5
Solution: Correct Answer: A
Explanation: Page 6 states a class is a user-defined data type for objects with similar
properties, e.g., a Fruit class for Mango and Apple. B is an object, C is procedural, and
D is not OOP.

18. What does encapsulation ensure?


A. Data is freely accessible.
B. Data is hidden from external access.
C. Objects inherit properties.
D. Operations vary by type.

Solution: Correct Answer: B


Explanation: Page 7 defines encapsulation as wrapping up of data and function with
data hidden, e.g., a balance accessible only via methods. A contradicts encapsulation,
C is inheritance, and D is polymorphism.

19. What is data abstraction?


A. Exposing all data details.
B. Representing essential features without details.
C. Sharing data globally.
D. Linking code at runtime.

Solution: Correct Answer: B


Explanation: Page 7 explains abstraction as representing essential features without
details, e.g., a class defining size and cost. A is the opposite, C is procedural, and D is
dynamic binding.

20. What does inheritance provide?


A. Data hiding.
B. Code reusability.
C. Operator overloading.
D. Message passing.

Solution: Correct Answer: B


Explanation: Page 7 states inheritance enables reusability by deriving new classes,
e.g., SavingsAccount from Account. A is encapsulation, C is polymorphism, and D is
communication.

21. What is polymorphism?

Page 6
A. Hiding data.
B. Operations behaving differently based on data.
C. Creating classes.
D. Compiling code.

Solution: Correct Answer: B


Explanation: Page 8 defines polymorphism as operations with different behavior by
type, e.g., ‘+‘ adding numbers or concatenating strings. A is encapsulation, C is class
definition, and D is unrelated.

22. What is dynamic binding?


A. Code linked at compile time.
B. Code linked at runtime.
C. Data hidden from access.
D. Objects communicating.

Solution: Correct Answer: B


Explanation: Page 9 explains dynamic binding as linking procedure calls to code
at run time, e.g., a draw method varying by object type. A is static binding, C is
encapsulation, and D is message passing.

23. What is message passing in OOP?


A. Objects sharing global data.
B. Objects sending requests to each other.
C. Compiling bytecode.
D. Inheriting properties.

Solution: Correct Answer: B


Explanation: Page 9 describes message passing as objects sending requests to invoke
methods, e.g., a customer requesting a balance. A is procedural, C is compilation, and
D is inheritance.

24. What is a benefit of OOP?


A. Increased global data access.
B. Code reusability through inheritance.
C. Mandatory use of events.
D. No use of functions.

Page 7
Solution: Correct Answer: B
Explanation: Page 10 lists code reusability via inheritance as an OOP benefit, e.g.,
reusing class features. A is a procedural flaw, C is event-driven, and D is false.

25. Why is data hiding important?


A. It allows global access.
B. It protects data from unintended changes.
C. It prevents object creation.
D. It disables inheritance.

Solution: Correct Answer: B


Explanation: Page 10 notes data hiding builds secure program[s] by preventing unin-
tended changes, e.g., encapsulated balance data. A is false, C and D are unrelated.

26. What is an Abstract Data Type (ADT)?


A. A class using abstraction.
B. A global variable.
C. A compilation error.
D. A procedure call.

Solution: Correct Answer: A


Explanation: Page 7 calls classes Abstract Data Types due to abstraction, e.g., a class
defining attributes. B is procedural, C is an error, and D is a function call.

27. How do objects communicate?


A. Through global variables.
B. Through message passing.
C. Through compilation.
D. Through direct data access.

Solution: Correct Answer: B


Explanation: Page 9 states objects communicate via message passing, not global vari-
ables (A), compilation (C), or direct access (D, prevented by encapsulation).

28. What does OOPs bottom-up approach mean?


A. Starting with procedures.
B. ăg From objects upward.

Page 8
C. Compiling first.
D. Using global data.

Solution: Correct Answer: B


Explanation: Page 4 notes OOP uses a bottom up approach, building from objects,
unlike procedural top-down (A), compilation (C), or global data (D).

29. What is operator overloading?


A. Hiding data.
B. An operator behaving differently by type.
C. Creating classes.
D. Linking code.

Solution: Correct Answer: B


Explanation: Page 8 explains operator overloading (polymorphism) as operators vary-
ing by type, e.g., ‘+‘ for numbers or strings. A is encapsulation, C is class creation,
and D is binding.

30. Why is OOP modular?


A. It uses global data.
B. It partitions data and functions.
C. It avoids objects.
D. It requires events.

Solution: Correct Answer: B


Explanation: Page 4 states OOP modulariz[es] programs by partitioning data and
functions into objects, unlike global data (A), avoiding objects (C), or event-driven
(D).

31. What is a benefit of polymorphism?


A. Global data access.
B. Shared interfaces for different objects.
C. Preventing inheritance.
D. Disabling methods.

Solution: Correct Answer: B


Explanation: Page 9 notes polymorphism allows shared external interface[s], e.g., a
draw method for different shapes. A is procedural, C and D are false.

Page 9
32. What does OOP enable for upgrades?
A. Complex upgrades.
B. Easy system upgrades.
C. No upgrades.
D. Only applet upgrades.

Solution: Correct Answer: B


Explanation: Page 10 states OOP systems can be easily upgraded, due to modularity,
unlike complex (A), no upgrades (C), or applet-only (D).

33. What is a classs role?


A. Execute bytecode.
B. Define object templates.
C. Compile code.
D. Handle events.

Solution: Correct Answer: B


Explanation: Page 6 explains classes as user-defined data type[s] for objects, e.g., a
Fruit class. A is the JVM, C is the compiler, and D is event-driven.

34. Why is OOP secure?


A. Global data access.
B. Data hiding.
C. No functions.
D. Event-driven.

Solution: Correct Answer: B


Explanation: Page 10 notes data hiding ensures secure program[s], e.g., protected data
in objects. A is procedural, C is false, and D is unrelated.

35. What supports hierarchical classification?


A. Encapsulation
B. Inheritance
C. Polymorphism
D. Message Passing

Page 10
Solution: Correct Answer: B
Explanation: Page 7 states inheritance supports hierarchical classification, e.g., a
robin as a flying bird. A, C, and D are other OOP concepts.

36. Why is Java portable?


A. Native code compilation.
B. Bytecode runs on JVM.
C. Specific hardware needs.
D. Browser-only execution.

Solution: Correct Answer: B


Explanation: Page 12 explains Javas bytecode is platform-independent, running on
any JVM, e.g., the same code on Windows or Linux. A is platform-specific, C contra-
dicts portability, and D is false.

37. What is a Java application?


A. Runs in a browser.
B. Runs on a machine with main().
C. Requires paint().
D. Cannot be compiled.

Solution: Correct Answer: B


Explanation: Page 12 states applications run directly on your machine with a main(),
e.g., a console program. A and C are applets, D is false.

38. What is a Java applet?


A. Runs on a machine with main().
B. Runs in a browser with HTML.
C. Cannot be compiled.
D. Uses native code.

Solution: Correct Answer: B


Explanation: Page 13 notes applets run over the Internet with HTML, e.g., in a
browser. A is an application, C and D are false.

39. Why is Java secure?


A. Global data access.
B. Security Manager and type checking.

Page 11
C. No memory management.
D. Browser-only execution.

Solution: Correct Answer: B


Explanation: Page 12 highlights Javas Security Manager and strong type checking for
security, e.g., sandbox execution. A is insecure, C is false, and D is incorrect.

40. What makes Java simple?


A. Complex syntax.
B. Automatic memory management.
C. No libraries.
D. Native code.

Solution: Correct Answer: B


Explanation: Page 12 notes Javas automatic memory management simplifies coding,
e.g., garbage collection. A, C, and D are false.

41. What is the Java platform?


A. A programming language.
B. JVM and libraries.
C. A compiler.
D. A browser.

Solution: Correct Answer: B


Explanation: Page 11 defines the Java platform as the JVM and libraries, e.g., for
hardware abstraction. A is the language, C is a tool, and D is incorrect.

42. Why is Java scalable?


A. Limited to mobile devices.
B. Supports performance and development.
C. No threading.
D. Browser-only.

Solution: Correct Answer: B


Explanation: Page 12 states Java is scalable for performance and development, e.g.,
from mobile to enterprise. A, C, and D are false.

43. What does Javas multi-threading enable?

Page 12
A. Single-thread execution.
B. Concurrent task execution.
C. No performance gain.
D. Browser-only tasks.

Solution: Correct Answer: B


Explanation: Page 12 notes Javas multi-threaded support for concurrent tasks, e.g.,
parallel processing. A, C, and D are incorrect.

44. What is the Java compilers output?


A. Native code.
B. Bytecode.
C. Source code.
D. HTML.

Solution: Correct Answer: B


Explanation: Page 12 explains the compiler produces bytecode, e.g., a .class file. A is
platform-specific, C is input, and D is for applets.

45. What does Javas dynamic feature allow?


A. Static code only.
B. Loading components at runtime.
C. No libraries.
D. Browser-only execution.

Solution: Correct Answer: B


Explanation: Page 12 states Java can load application components at run-time, e.g.,
dynamic class loading. A, C, and D are false.

46. What is bytecode?


A. Source code.
B. Platform-independent code.
C. Native code.
D. HTML code.

Page 13
Solution: Correct Answer: B
Explanation: Page 14 defines bytecode as platform-independent code from the com-
piler, e.g., .class files. A is pre-compilation, C is platform-specific, and D is for applets.

47. What does the JVM do?


A. Compiles source code.
B. Executes bytecode.
C. Edits code.
D. Creates HTML.

Solution: Correct Answer: B


Explanation: Page 16 states the JVM manipulates bytecode for execution, e.g., run-
ning .class files. A is the compiler, C is an editor, and D is unrelated.

48. What is the JRE?


A. A compiler.
B. JVM and libraries for running programs.
C. A programming language.
D. A debugger.

Solution: Correct Answer: B


Explanation: Page 16 defines the JRE as the JVM and libraries for running Java, e.g.,
runtime support. A, C, and D are incorrect.

49. What is a compilation error?


A. Runtime error.
B. Syntax error detected by the compiler.
C. Execution error.
D. Hardware error.

Solution: Correct Answer: B


Explanation: Page 15 notes compilation errors are violation of syntax rules, e.g., miss-
ing semicolons. A and C are runtime, D is unrelated.

50. What is the JDK?


A. A runtime environment only.
B. Development tools including JRE.

Page 14
C. A browser.
D. A bytecode file.

Solution: Correct Answer: B


Explanation: Page 16 defines the JDK as development tools including the JRE, e.g.,
javac. A is the JRE, C and D are incorrect.

Page 15

You might also like