Introduction to Object Oriented Programming
Assignment - 1
MCQs
1. What is Object-Oriented Programming (OOP)?
a) A programming paradigm based on functions
b) A programming paradigm based on structured programming
c) A programming paradigm based on objects and classes
d) A low-level programming approach
2. Which of the following is NOT a feature of OOP?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Compilation
3. In OOP, what does encapsulation refer to?
a) Combining multiple programs into one
b) Hiding implementation details and restricting access
c) The ability to inherit properties from another class
d) The ability to have multiple functions with the same name
4. What is the primary advantage of inheritance in OOP?
a) Increases code duplication
b) Reduces code reuse
c) Allows new classes to derive properties from existing ones
d) Increases program execution time
5. Which keyword is used to define a class in Java?
a) class
b) struct
c) object
d) define
6. What is an object in OOP?
a) A data type
b) A function
c) An instance of a class
d) A class itself
7. What is polymorphism in OOP?
a) The ability of objects to be created dynamically
b) The ability of a variable to change its data type
c) The ability of a function to take multiple forms
d) The ability of a program to execute faster
8. Which of the following concepts allows a class to use the properties of another class?
a) Abstraction
b) Encapsulation
c) Inheritance
d) Polymorphism
9. Which of these is an example of a programming language that supports OOP?
a) C
b) Assembly
c) Java
d) COBOL
10. What is abstraction in OOP?
a) Hiding unnecessary details and showing only the essential features
b) Hiding data to ensure security
c) The process of breaking code into smaller modules
d) The ability to create multiple functions with the same name
Fill in the blanks
1. The special method that is automatically called when an object is created is called a
______.
2. A constructor that takes no parameters is called a ______ constructor.
3. In Java, an interface can have only ______ methods by default.
4. The keyword used to implement an interface in Java is ______.
5. In multiple inheritance, a class can inherit from multiple ______.
Answer the following questions:
1. What is Object-Oriented Programming (OOP)?
2. Name any four key features of OOP.
3. What is a class in Java?
4. Define an object in the context of OOP.
5. What is encapsulation? Why is it important?