MCQs on Object-Oriented Concepts in Core Java | Advanced OOP in Java

Object-Oriented Concepts in Core Java | Advanced OOP in Java: MCQs for Mastery

Dive into essential concepts of Object-Oriented Programming (OOP) in Core Java. This set of 30 MCQs is crafted for Java enthusiasts aiming to strengthen their knowledge of classes, objects, constructors, static blocks, method overriding, method overloading, and encapsulation in Java. Enhance your understanding of advanced OOP principles and become proficient in applying Java access modifiers.


MCQs

1-10: Deep Dive into Classes and Objects

  1. Which of the following is true about a class in Java?
    • A) A blueprint for objects
    • B) It contains only static methods
    • C) It represents a single instance
    • D) None of the above
  2. In Java, an object is an instance of:
    • A) A variable
    • B) A class
    • C) A method
    • D) A primitive data type
  3. Which statement about classes and objects is incorrect?
    • A) Classes can contain fields and methods
    • B) Objects can directly hold multiple instances of classes
    • C) An object is created from a class
    • D) A class can have multiple instances
  4. How can we access members of an object in Java?
    • A) Using the class name
    • B) Using the object reference
    • C) Using static access
    • D) None of the above
  5. The keyword new in Java is used for:
    • A) Declaring a new class
    • B) Creating an instance of a class
    • C) Creating a new method
    • D) Initializing a variable
  6. In Java, which of the following keywords is used to create an instance of a class?
    • A) init
    • B) this
    • C) new
    • D) create
  7. Which of the following is not a characteristic of an object?
    • A) State
    • B) Behavior
    • C) Identification
    • D) Abstraction
  8. What does this keyword represent within a class?
    • A) Current object instance
    • B) Parent class
    • C) Child class
    • D) None of the above
  9. Objects in Java are stored in:
    • A) Stack memory
    • B) Heap memory
    • C) Register memory
    • D) Class memory
  10. A constructor is primarily used to:
  • A) Define the structure of the class
  • B) Instantiate objects of the class
  • C) Access object variables
  • D) Destroy objects

11-15: Constructors and Static Blocks

  1. What is the role of a constructor in Java?
  • A) To initialize a class
  • B) To initialize an object
  • C) To define method behavior
  • D) To terminate a class
  1. Which of the following statements about static blocks is correct?
  • A) They execute only once
  • B) They execute every time a method is called
  • C) They can access non-static variables
  • D) They are called explicitly
  1. What is a default constructor?
  • A) A constructor defined by the programmer
  • B) A no-argument constructor provided by Java if none is specified
  • C) A constructor with parameters
  • D) None of the above
  1. When does a static block execute in Java?
  • A) When the program ends
  • B) During object creation
  • C) When the class is loaded
  • D) None of the above
  1. How many times can a static block run per class?
  • A) As many times as there are objects
  • B) Only once, when the class is loaded
  • C) Twice for each method call
  • D) Every time a variable is used

16-20: Method Overriding and Overloading

  1. Which of the following methods can be overridden?
  • A) Static methods
  • B) Instance methods
  • C) Private methods
  • D) Final methods
  1. Method overloading is achieved by:
  • A) Changing method name
  • B) Changing the parameter list
  • C) Changing return type
  • D) Using the final keyword
  1. Which of the following is a valid example of method overriding?
  • A) public void display()
  • B) static void show()
  • C) private void set()
  • D) public final void get()
  1. Can two methods have the same name if they differ only by return type?
  • A) Yes
  • B) No
  • C) Only in certain cases
  • D) Depends on visibility
  1. Which keyword is used to access a superclass method when overriding?
  • A) this
  • B) base
  • C) super
  • D) parent

21-25: Access Modifiers and Encapsulation

  1. Which access modifier allows a method to be accessible within the same package but not from outside?
  • A) public
  • B) private
  • C) protected
  • D) default (no modifier)
  1. A private variable in a class can be accessed:
  • A) Directly from another class
  • B) Only through getter and setter methods
  • C) By using the protected keyword
  • D) Using this keyword
  1. Which of the following best defines encapsulation?
  • A) Hiding the implementation details from the user
  • B) Using the same method name with different parameters
  • C) Accessing fields directly
  • D) Inheriting from another class
  1. What is the benefit of using encapsulation in Java?
  • A) To allow unrestricted access to fields
  • B) To control object properties and restrict data manipulation
  • C) To override static methods
  • D) None of the above
  1. Encapsulation can be implemented in Java using:
  • A) Constructors only
  • B) Private variables and public methods
  • C) Static blocks
  • D) Public fields only

26-30: Miscellaneous Advanced OOP Concepts

  1. Can a Java class have more than one static block?
  • A) Yes, and they will run sequentially
  • B) No, only one is allowed
  • C) Yes, but only one will execute
  • D) None of the above
  1. Which access modifier can be used to make a variable accessible across all classes in Java?
  • A) protected
  • B) private
  • C) public
  • D) default
  1. If a method in the superclass is marked as final, then:
  • A) It cannot be overridden
  • B) It can be overridden
  • C) It must be overloaded
  • D) It becomes abstract
  1. What is an advantage of method overloading in Java?
  • A) It enhances code readability
  • B) It forces object inheritance
  • C) It reduces memory usage
  • D) It allows cross-package access
  1. Which keyword prevents a class from being extended?
  • A) static
  • B) abstract
  • C) final
  • D) synchronized

Answer Key

QnoAnswer
1A) A blueprint for objects
2B) A class
3B) Objects can directly hold multiple instances of classes
4B) Using the object reference
5B) Creating an instance of a class
6C) new
7D) Abstraction
8A) Current object instance
9B) Heap memory
10B) Instantiate objects of the class
11B) To initialize an object
12A) They execute only once
13B) A no-argument constructor provided by Java if none is specified
14C) When the class is loaded
15B) Only once, when the class is loaded
16B) Instance methods
17B) Changing the parameter list
18A) public void display()
19B) No
20C) super
21D) default (no modifier)
22B) Only through getter and setter methods
23A) Hiding the implementation details from the user
24B) To control object properties and restrict data manipulation
25B) Private variables and public methods
26A) Yes, and they will run sequentially
27C) public
28A) It cannot be overridden
29A) It enhances code readability
30C) final

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top