java 12) Which of the following statements declares Salaried as a subclass of Pa
ID: 3834512 • Letter: J
Question
java
12)
Which of the following statements declares Salaried as a subclass of PayType?
_
A)
public class Salaried derivedFrom(Paytype)
B)
public class PayType derives Salaried
C)
public class Salaried implements PayType
D)
public class Salaried extends PayType
13)
If a class contains an abstract method,
_
A)
The method must be overridden in subclasses
B)
You cannot create an instance of the class
C)
The method will have only a header, but not a body, and end with a semicolon
D)
All of the above
14)
In the following code, what will the call to super do?
public class ClassB extends ClassA
{
public ClassB()
{
super(40);
System.out.println("This is the last statement "); }
______
A)
It will call the method super and pass the value 40 to it as an argument
B)
This cannot be determined form the above code
C)
It will call the constructor of ClassA that receives an integer as an argument
D)
The method super will have to be defined before we can say what will happen
15)
In the following statement, which is the subclass?
public class ClassA extends ClassB implements ClassC
_
A)
ClassA
B)
ClassB
C)
ClassC
D)
Cannot tell
Explanation / Answer
12) public class Salaried extends PayType
Extends is used where inheritance relation is there .. there is no derived from or derived keyword and implements is used for implementing interfaces.
13) D) All of the above .. if there is an abstract method in class ,then that class is abstract class . An abstract class cannot be instantiated. The abstract method does not have a body in abstract class and it needs to be defined in subclasses.
14)It will call the constructor of ClassA that receives an integer as an argument
super keyword is used to call the constructor of parent class. It should be first line in the constructor of child class.
15) class A is the subclass here .. class B is parent class and class C is interface which is implemented by class A
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.