Computer science JAVA multiple choice questions Question 16 Which of the followi
ID: 667742 • Letter: C
Question
Computer science JAVA multiple choice questions
Question 16
Which of the following can contain a constructor?
Question 16 options:
Any abstract class or interface
Any nonabstract or abstract class
Any class or interface
Any nonabstract class or interface
Question 17
What is the output the program shown below.
interface A
{
}
class D extends C
{
}
class C
{
}
class B extends D implements A
{
}
public class Quiz2F
{
public static void main(String[] args)
{
B b = new B();
if (b instanceof A)
System.out.println("b is an instance of A");
if (b instanceof C)
System.out.println("b is an instance of C");
}
}
Question 17 options:
b is an instance of A
Nothing
b is an instance of C
b is an instance of A followed by b is an instance of C
Question 18
Which of the following class definitions defines a legal abstract class?
Question 18 options:
abstract class A { abstract void unfinished(); }
public class abstract A { abstract void unfinished(); }
class A { abstract void unfinished(); }
class A { abstract void unfinished() { } }
Question 19
Which of the following statements regarding abstract methods is not true?
Question 19 options:
Abstract classes can have constructors
It is possible to declare an abstract class that contains no abstract methods
A data field can be declared abstract
A class that contains abstract methods must be abstract
Question 20
What is true about using the reserved word super?
Question 20 options:
It can only be used in a class that contains an extends clause
It can only be used in a constructor
It can only be used in subclasses
It can only be used in superclasses
Explanation / Answer
Question 16)
Therefore the correct option is “Any non-abstract or abstract class”.
Question 17)
Therefore the correct option is “b is an instance of A followed by b is an instance of C”.
Question 18)
abstract class CLASSNAME{
//declarations of data and non-abstract methods
//declarations of abstract methods
Therefore the correct option is “abstract class A {abstract void unfinished(); }”.
Question 19)
Therefore the correct option is “A data field can be declared abstract”.
Question 20)
Therefore the correct option is “It can only be used in subclasses”.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.