Java Programming — OOP in Java
Java OOP, collections, multithreading
100 Questions 10 Topics Take Test
Advertisement
Showing 71–80 of 100 questions in OOP in Java
Q.71 Medium OOP in Java
Which of the following correctly implements method overloading rules in Java?
A Methods must have the same name and same parameter types
B Methods must have the same name but different parameter types, number, or order
C Methods must have different names and different return types
D Methods can have same name with different return types only
Correct Answer:  B. Methods must have the same name but different parameter types, number, or order
EXPLANATION

Method overloading requires methods to have the same name but different parameter lists (different types, number, or order of parameters). Return type alone cannot distinguish overloaded methods.

Take Test
Q.72 Medium OOP in Java
An abstract class in Java cannot be instantiated, but it can have concrete methods. Which statement explains why?
A Abstract classes are incomplete and cannot have objects
B Abstract classes serve as templates and concrete methods provide default implementations that subclasses can use
C Abstract methods do not allow concrete methods in the same class
D Concrete methods in abstract classes are automatically inherited as abstract
Correct Answer:  B. Abstract classes serve as templates and concrete methods provide default implementations that subclasses can use
EXPLANATION

Abstract classes cannot be instantiated but can contain both abstract methods (without implementation) and concrete methods (with implementation). This allows providing default behavior while enforcing certain methods to be implemented by subclasses.

Take Test
Q.73 Medium OOP in Java
Which of the following best describes polymorphism in Java?
A The ability to create multiple classes from a single parent class
B The ability of an object to take multiple forms or for objects to behave differently in different contexts
C The ability to hide internal implementation details
D The ability to combine data and methods in a single unit
Correct Answer:  B. The ability of an object to take multiple forms or for objects to behave differently in different contexts
EXPLANATION

Polymorphism allows objects to be treated as instances of their parent class and to call methods that are overridden in child classes. It includes method overloading and method overriding.

Take Test
Q.74 Medium OOP in Java
What is the difference between 'this' and 'super' keywords in Java?
A 'this' refers to parent class and 'super' refers to current class
B 'this' refers to current class object and 'super' refers to parent class
C Both are identical and can be used interchangeably
D 'this' is used in interfaces and 'super' is used in abstract classes
Correct Answer:  B. 'this' refers to current class object and 'super' refers to parent class
EXPLANATION

'this' is a reference to the current object instance, while 'super' is a reference to the parent class object. They are used to access members of current and parent classes respectively.

Take Test
Q.75 Medium OOP in Java
In the context of constructors, which statement is correct?
A Constructors can have return types
B A class can have multiple constructors with different parameter lists
C Constructors are inherited like other methods
D Constructors must be declared as public
Correct Answer:  B. A class can have multiple constructors with different parameter lists
EXPLANATION

Constructor overloading is allowed in Java. A class can have multiple constructors with different parameter lists. Constructors don't have return types and can have any access modifier.

Take Test
Q.76 Medium OOP in Java
Which of the following statements about 'instanceof' operator is true?
A It is used to compare two objects for equality
B It checks if an object is an instance of a specific class or interface
C It creates a new instance of a class
D It is used only with abstract classes
Correct Answer:  B. It checks if an object is an instance of a specific class or interface
EXPLANATION

The 'instanceof' operator is used to test if an object is an instance of a specified class, subclass, or interface. It returns a boolean value.

Take Test
Q.77 Easy OOP in Java
In Java OOP, which principle ensures that internal details of a class are hidden from the outside world?
A Inheritance
B Polymorphism
C Encapsulation
D Abstraction
Correct Answer:  C. Encapsulation
EXPLANATION

Encapsulation is the bundling of data and methods into a single unit (class) while hiding internal implementation details using access modifiers.

Take Test
Q.78 Medium OOP in Java
Which of the following correctly describes method overriding in Java?
A Methods with the same name but different parameters in the same class
B Methods with the same signature in parent and child classes with @Override annotation
C Creating multiple methods with same name in different classes
D Methods that cannot be inherited
Correct Answer:  B. Methods with the same signature in parent and child classes with @Override annotation
EXPLANATION

Method overriding occurs when a child class provides a specific implementation of a method already defined in the parent class with the same signature. The @Override annotation is optional but recommended.

Take Test
Q.79 Easy OOP in Java
What is the primary purpose of using the 'super' keyword in Java?
A To create an object of parent class
B To access parent class methods and constructors
C To prevent method overriding
D To declare a variable as final
Correct Answer:  B. To access parent class methods and constructors
EXPLANATION

'super' is used to refer to parent class methods, constructors, and variables. It helps in accessing hidden or overridden members of the parent class.

Take Test
Q.80 Medium OOP in Java
Which of the following statements about inheritance in Java is correct?
A A class can inherit from multiple classes directly
B A class can implement multiple interfaces
C An interface can extend multiple interfaces
D Both B and C are correct
Correct Answer:  D. Both B and C are correct
EXPLANATION

Java supports single inheritance for classes but a class can implement multiple interfaces. An interface can extend multiple interfaces through multiple inheritance.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips