Answer the correct option. Question 5 What can an abstract class contain? Questi
ID: 3719463 • Letter: A
Question
Answer the correct option.
Question 5
What can an abstract class contain?
Question 5 options:
constructors, instance variables, instance methods, abstract methods, static methods, static variables
constructors, instance variables, instance methods, abstract methods,
abstract methods, static methods, static variables
instance variables, instance methods, abstract method
Question 6
What is the use of the keyword super in a subclass?
Question 6 options:
It provides access to the constructor of the superclass.
It provides access to an instance method of the superclass.
It provides access to a public instance variable of the superclass.
All of the above.
None of the above
Question 7
What is the purpose of a constructor in a subclass.
Question 7 options:
To initialize value of the subclasses' private and public instance variable through assignment statements (eg. this.x = 1)
To initialize the value of the subclasses' public and private instance variables and the superclasses' private and public instance variables through assignment statements. (super.x = 1; this.y = 2)
To use a super constructor to initialize the value of the superclasses' instance variables.
To initialize value of the subclasses' private and public instance variable through assignment statements (eg. this.x = 1) and
use a super constructor to initialize the value of the superclasses' instance variables.
Question 8
Abstract classes can not be instantiated.
Question 8 options:
Question 9
Which of the following is a correct implementation of polymorphism. Note, object B extends object A.
Question 9 options:
B obj1 = new A();
A ob1 = new A();
B obj1 = new B();
A obj1 = new B();
Question 10
Interfaces differ from Abstract class because:
Question 10 options:
a class can implement many interfaces, but can only extend one abstract class
abstract classes create a hierarchy but interfaces do not
interfaces can only contain abstract methods and no implementations
all of the above
Question 11
Given this code snippet,
what will this program print?
Question 11 options:
This code causes an error.
Mike
Mike
Bob
Bob
Mike
Mike
Bob
Bob
Mike
Bob
Question 12
Based on this code snippet
what does this program output?
Question 12 options:
Shape Rectangle Rectangle Circle
Shape Shape Shape Shape
Shape Shape Shape Circle
This code will error
Shape Rectangle Square Circle
Shape Rectangle Rectangle Oval
constructors, instance variables, instance methods, abstract methods, static methods, static variables
constructors, instance variables, instance methods, abstract methods,
abstract methods, static methods, static variables
instance variables, instance methods, abstract method
Explanation / Answer
5) Answer : constructos, instance variables, instance methods, abstract methods, static methods, static variables
6) All of the above.
7)TO initialize value of the subclasses' private and public instance variable through assignment statements (eg. this.x = 1) and use a super constructor to initialize the value of the superclasses' instance variables.
8)True
9) A ob1 = new B();
10)all of the above
11)
Bob
Mike
Mike
Answer: Shape Shape Shape Circle
Thanks