Java this and super Keywords: 17 MCQs

All 17 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 7 questions

Q1. Which statement best describes the difference between `this` and `super`?

Beginner
A `this` is the parent object; `super` is the current object.
B `this` is the current object; `super` is the parent view of it.
C `this` is a variable; `super` is a keyword.
D `this` and `super` are two separate objects created at runtime.

Answers and explanations are in the Veda app.

Q2. Inside which of the following can `this` legally appear?

Beginner
A A static initializer block
B An instance method
C A static nested class's static method
D A static method

Answers and explanations are in the Veda app.

Q3. What does the statement `this.name = name;` do inside a constructor?

Beginner
A Assigns the field to the parameter
B Assigns the parameter to the instance field
C Assigns the parameter to itself
D Creates a new field named `name`

Answers and explanations are in the Veda app.

Q4. What is the required position of a `this(...)` constructor call within a constructor?

Beginner
A It must appear immediately after `super(...)`
B It can appear anywhere in the body
C It must be the last statement
D It must be the first statement

Answers and explanations are in the Veda app.

Q5. Which of these is a valid use of `this`?

Beginner
A Storing it in a variable: `Object o = this;` inside a static method
B Calling a grandparent method: `this.super.method();`
C Passing the current object to another method: `register(this);`
D Assigning a new object: `this = new Foo();`

Answers and explanations are in the Veda app.

Q6. Which statement about `this` and `super` is TRUE?

Beginner
A They refer to two distinct objects created at runtime.
B They are keywords, not variables, and cannot be reassigned.
C They are variables that can be reassigned to new objects.
D They can be used freely inside static methods.

Answers and explanations are in the Veda app.

Q7. Every constructor that does not explicitly call `this(...)` or `super(...)` receives an implicit `super()` call as its first statement, which is why a subclass fails to compile when the parent lacks a no-arg constructor.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Building up · 5 questions

Q8. A `Student` class has field `name` and a constructor parameter also called `name`. The constructor body is just `name = name;`. What is the field's value after construction?

Intermediate
A It remains `null` (or its default), unchanged
B It equals the constructor argument
C It causes a compile error
D It causes a runtime exception

Answers and explanations are in the Veda app.

Q9. A subclass constructor writes neither `this(...)` nor `super(...)`. What does the compiler do?

Intermediate
A Leaves the constructor with no parent call
B Raises a compile error for the missing call
C Inserts an implicit `super()` as the first statement
D Inserts an implicit `this()` as the first statement

Answers and explanations are in the Veda app.

Q10. `Animal.speak()` returns `"..."`. `Dog` overrides `speak()` as `return super.speak() + " Woof";`. What does `new Dog().speak()` return?

Intermediate
A `"... Woof"`
B `"..."`
C `"Woof"`
D A compile error, since `super` cannot be used in a return

Answers and explanations are in the Veda app.

Q11. A class has constructors `Point()` and `Point(int x, int y)`. Which body correctly chains `Point()` to the two-arg constructor?

Intermediate
A `Point(0, 0);`
B `super(0, 0);`
C `this(0, 0);`
D `new Point(0, 0);`

Answers and explanations are in the Veda app.

Q12. In a subclass, `super.field` is used to access what?

Intermediate
A A subclass-only field not present in the parent
B A private field of the grandparent class
C A static field of the parent class
D A parent field hidden by a same-named subclass field

Answers and explanations are in the Veda app.

Topper level · 5 questions

Q13. The parent class `Animal` defines only `Animal(int age)`. A subclass `Dog` has a constructor with no explicit `super(...)` or `this(...)`. What happens?

Advanced
A Compiles fine; the parent's `age` defaults to 0
B Compilation fails: no matching no-arg parent constructor
C Compiles fine; the compiler picks `Animal(int)` automatically
D Compiles but throws at runtime when `Dog` is instantiated

Answers and explanations are in the Veda app.

Q14. Why does `super.super.method()` fail to compile?

Advanced
A `super` is a variable, so chaining is not allowed
B `super` reaches only the immediate parent, not the grandparent
C `super` can only be used in constructors, not methods
D `super` requires a cast to the grandparent type first

Answers and explanations are in the Veda app.

Q15. Which pair of statements about `this(...)` and `super(...)` is correct?

Advanced
A Each must be last; they can both appear in one constructor.
B Each must be first; they cannot both appear in one constructor.
C Neither has a position rule, but they cannot be combined.
D `this(...)` must be first, but `super(...)` may appear anywhere.

Answers and explanations are in the Veda app.

Q16. A developer overrides `equals` in a class and writes `return this.id == other.id;`. What role does `this` play here?

Advanced
A It refers to the current object being compared
B It creates a new instance for comparison
C It refers to the parent class's `id` field
D It is illegal inside `equals` and causes a compile error

Answers and explanations are in the Veda app.

Q17. Consider the following class definitions: ```java class Parent { Parent(int x) { } } class Child extends Parent { Child() { this(5); } Child(int x) { super(x); } } ``` What happens when you try to instantiate `Child` using `new Child();`?

Advanced
A A runtime error occurs due to the absence of a no-arg constructor in Parent.
B The Child object is created with the Parent constructor being called with 5.
C A compilation error occurs because `super()` is not called in the constructor.
D The code compiles successfully and creates a Child object.

Answers and explanations are in the Veda app.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages