100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Inheritance and Polymorphism Exam- Questions & Answers 100% Correct| Newest Update 2025

Rating
-
Sold
-
Pages
29
Grade
A+
Uploaded on
28-12-2024
Written in
2024/2025

Inheritance and Polymorphism Exam- Questions & Answers 100% Correct| Newest Update 2025

Institution
E.x.a.m.s
Course
E.x.a.m.s










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
E.x.a.m.s
Course
E.x.a.m.s

Document information

Uploaded on
December 28, 2024
Number of pages
29
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Inheritance and Polymorphism Exam- Questions &
Answers 100% Correct| Newest Update 2025
11.7 Which of the following is incorrect?
A. A constructor may be static.
B. A constructor may be private.
C. A constructor may invoke a static method.
D. A constructor may invoke an overloaded constructor.
E. A constructor invokes its superclass no-arg constructor by default if a constructor
does not invoke an overloaded constructor or its superclass?s constructor. - ✔✔A. A
constructor may be static.


11.8 Which of the statements regarding the super keyword is incorrect?
A. You can use super to invoke a super class constructor.
B. You can use super to invoke a super class method.
C. You can use super.super.p to invoke a method in superclass's parent class.

D. You cannot invoke a method in superclass's parent class. - ✔✔C. You can use
super.super.p to invoke a method in superclass's parent class.


11.9 Analyze the following code:


public class Test {
public static void main(String[] args) {
B b = new B();
b.m(5);
System.out.println("i is " + b.i);
}

,}


class A {
int i;


public void m(int i) {
this.i = i;
}
}


class B extends A {
public void m(String s) {
}
}
A. The program has a compile error, because m is overridden with a different signature
in B.
B. The program has a compile error, because b.m(5) cannot be invoked since the
method m(int) is hidden in B.
C. The program has a runtime error on b.i, because i is not accessible from b.
D. The method m is not overridden in B. B inherits the method m from A and defines an
overloaded method m in B. - ✔✔D. The method m is not overridden in B. B inherits
the method m from A and defines an overloaded method m in B.


11.10 The getValue() method is overridden in two ways. Which one is correct?


I:
public class Test {

, public static void main(String[] args) {
A a = new A();
System.out.println(a.getValue());
}
}


class B {
public String getValue() {
return "Any object";
}
}


class A extends B {
public Object getValue() {
return "A string";
}
}


II:
public class Test {
public static void main(String[] args) {
A a = new A();
System.out.println(a.getValue());
}
}

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
QUINTER New York College Of Dentistry
View profile
Follow You need to be logged in order to follow users or courses
Sold
339
Member since
2 year
Number of followers
104
Documents
38211
Last sold
18 hours ago

3.4

57 reviews

5
25
4
8
3
7
2
1
1
16

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions