Question
1. Consider the following code: public class One { //implementation not shown } public class Two extends One { //implementation not shown } public class
1. Consider the following code: public class One { //implementation not shown } public class Two extends One { //implementation not shown } public class Three extends One { //implementation not shown } Which of the following statements is true?
- Two inherits from One, and Three inherits from Two.
- Three has Two as its direct superclass.
- Two and Three are both subclasses of One.
A)I only
B)III only
C)I and II only
D)I and III only
E)I, II, and III
2. Consider the following partial class declarations for the Triangle and EquilateralTriangle classes: public class Triangle { private int side1, side2, side3; public Triangle (int a, int b, int c) { side1 = a; side2 = b; side3 = c; } // other code not shown } public class EquilateralTriangle extends Triangle { public EquilateralTriangle(int s) { < missing code > } // other code not shown } What code should replace < missing code >?
A)super();
B)super(s);
C)super(int s);
D)super(s, s, s);
E)super(side1, side2, side3);
3. What is the keyword that invokes the constructor of the current class's parent class?
A)class
B)extends
C)private
D)public
E)super
4.
What is a collection formed by a class and all its subclasses?
A)Class hierarchy
B)Extending classes
C)Inheritance
D)Polymorphism
E)Subclass
5.
Which of the following statements is true?
- A class has only one direct super class.
- A class can have multiple subclasses.
- A class can extend multiple classes.
A)I only
B)II only
C)III only
D)I and II only
E)II and III only
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started