How do we call the following constructor of the super class \"Line\" from a subc
ID: 3868321 • Letter: H
Question
How do we call the following constructor of the super class "Line" from a subclass "Square"? public Class Line{ private integer length; public Line(int length){this.length=length} }
a. public Class Square extends Line{ public Square(int length){Square.super(length);} }
b. public Class Square extends Line{ public Square(int length){super.Line(length);} }
c. public Class Square extends Line{ public Square(int length){super(length);} }
d. public Class Square extends Line{ public Square(int length){Line.super(length);} }
2.
Class A "is-a" Class B. This demonstrates _____________________.
polymorphism
composition
inheritance
d
.
encapsulation
3.
Which of the following is not true?
Static methods are not inherited.
Constructor Methods are inherited.
Java.lang gets imported to all of the java classes automatically.
A java class can not inherit from more than one class.
a.polymorphism
b.composition
c.inheritance
d
.
encapsulation
3.
Which of the following is not true?
a.Static methods are not inherited.
b.Constructor Methods are inherited.
c.Java.lang gets imported to all of the java classes automatically.
d.A java class can not inherit from more than one class.
Explanation / Answer
1. C) public Class Square extends Line{ public Square(int length){super(length);}
This line strictly follows the syntax of a constructor.
2. C) Inheritance
'is-a' means a relation between one class to the other class which means that one is inherited from the other.
3. A) Static methods are not inherited.
This statement is false because Static methods can be inherited but not in case of polymorphism.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.