Home Subjects Java Programming

Java Programming

Java OOP, collections, multithreading

958 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 831–840 of 958
Topics in Java Programming
Q.831 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.832 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.833 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.834 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.835 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.836 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.837 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.838 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
Q.839 Easy OOP in Java
In Java, which keyword is used to create a reference variable that cannot point to a different object after initialization?
A static
B final
C volatile
D synchronized
Correct Answer:  B. final
EXPLANATION

The 'final' keyword when applied to a reference variable makes it immutable, meaning it cannot be reassigned to point to another object.

Take Test
Q.840 Easy OOP in Java
Which of the following access modifiers allows a variable to be accessed only within the same class?
A private
B protected
C public
D default
Correct Answer:  A. private
EXPLANATION

The 'private' access modifier restricts access to only within the same class. It provides the highest level of encapsulation.

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