Java Programming
Java OOP, collections, multithreading
476 Questions 10 Topics Take Test
Advertisement
Showing 411–420 of 476 questions
Q.411 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.412 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.413 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.414 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.415 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.416 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.417 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.418 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.419 Medium OOP in Java
Which of the following statements about 'instanceof' operator is correct?
A It checks if an object is created from a class
B It checks if an object is an instance of a class or interface
C It checks if a variable is static
D It converts object type
Correct Answer:  B. It checks if an object is an instance of a class or interface
EXPLANATION

The 'instanceof' operator checks whether an object is an instance of a specific class or implements a specific interface.

Take Test
Q.420 Medium OOP in Java
What is the output?

class A {
A() {
System.out.println("A");
}
}
class B extends A {
B() {
super();
System.out.println("B");
}
}
public class Test {
public static void main(String[] args) {
new B();
}
}
A B then A
B A then B
C Only B
D Compilation Error
Correct Answer:  B. A then B
EXPLANATION

super() calls parent constructor first. Parent constructor A prints 'A', then child constructor B prints 'B'.

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