ExamVeda
Login
Home
1
What is inheritance in Java?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
2
In Java, which keyword is used to implement inheritance between classes?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
3
What is a superclass in Java?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
4
In Java, can a subclass inherit constructors from its superclass?
Discuss
Answer & Solution
Answer: Option D
Solution:
Option A: Only if the subclass is marked as "final"

This option is incorrect. Marking a subclass as "final" means that it cannot be subclassed further, and it has no impact on the inheritance of constructors.

Option B: Yes, a subclass inherits constructors from its superclass

This option is incorrect. In Java, a subclass does not inherit constructors from its superclass. However, a subclass can call the constructors of its superclass using the super keyword.

Option C: Only if the superclass is marked as "static"

This option is incorrect. The "static" keyword cannot be applied to classes or constructors in a way that would affect inheritance.

Option D: None of the above

This option is correct. In Java, constructors are not inherited by subclasses. Subclasses must explicitly define their own constructors, although they can call their superclass's constructors using the super keyword.

Conclusion:

In Java, a subclass does not inherit constructors from its superclass, making Option D: None of the above the correct answer.
5
What is method overriding in Java?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
6
In Java, can a subclass override a private method from its superclass?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
7
What is the "super" keyword used for in Java?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
8
What is the result of the following code snippet?

class Parent {
void display() {
System.out.println("Parent");
}
}
class Child extends Parent {
void display() {
System.out.println("Child");
}
}
public class Main {
public static void main(String[] args) {
Parent obj = new Child();
obj.display();
}
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
9
In Java, can a subclass access private members (fields and methods) of its superclass?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
10
What is the difference between "extends" and "implements" in Java?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board