Quiz on Super Keyword in Java
The super keyword in Java is used to refer to the immediate parent class of an object. It allows access to parent class methods, constructors, and variables, especially when overridden in child classes.
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
- Question 1 of 15
1. Question
What does the super keyword in Java refer to?
CorrectIncorrect - Question 2 of 15
2. Question
Which of the following is a valid use of the super keyword?
CorrectIncorrect - Question 3 of 15
3. Question
When is super() used in a constructor?
CorrectIncorrect - Question 4 of 15
4. Question
Where must super() be placed inside a constructor?
CorrectIncorrect - Question 5 of 15
5. Question
If super() is not written in a child class constructor, what happens?
CorrectIncorrect - Question 6 of 15
6. Question
What happens if the parent class has a parameterized constructor but child does not call it?
CorrectIncorrect - Question 7 of 15
7. Question
Can super be used to call a method that is overridden in the child class?
CorrectIncorrect - Question 8 of 15
8. Question
What is printed in the following code?
class A { void show() { System.out.println(“A”); } }
class B extends A { void show() { super.show(); System.out.println(“B”); } }CorrectIncorrect - Question 9 of 15
9. Question
Which of the following is NOT allowed using super keyword?
CorrectIncorrect - Question 10 of 15
10. Question
Can you use super in a static context?
CorrectIncorrect - Question 11 of 15
11. Question
What will the following code print?
class Animal { String name = “Animal”; }
class Dog extends Animal { String name = “Dog”; void print() { System.out.println(super.name); } }CorrectIncorrect - Question 12 of 15
12. Question
Can super() be used in a method to call a parent class constructor?
CorrectIncorrect - Question 13 of 15
13. Question
Is it possible to call a constructor from a superclass with parameters?
CorrectIncorrect - Question 14 of 15
14. Question
What will happen if super() is not the first line in a constructor?
CorrectIncorrect - Question 15 of 15
15. Question
How can you differentiate variables with the same name in parent and child class?
CorrectIncorrect
Summary
The super keyword in Java is vital for accessing parent class properties, constructors, and overridden methods. It enhances code reusability and clarity, especially in inheritance hierarchies.
