Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Computer science JAVA multiple choice questions Question 11 Which of the followi

ID: 667740 • Letter: C

Question

Computer science JAVA multiple choice questions

Question 11

Which of the following statements about type compatibility is true?

Question 11 options:

An object of a subclass can be assigned to a reference to its superclass without a type cast

Assigning an object of a superclass to a reference to one of its subclasses always causes a compilation error whether type casting is used or not

An object of a subclass can be assigned to a reference to its superclass, but type casting is required

An object of a superclass can be assigned to a reference to one of its subclasses without casting

Question 12

Which of the following statements about final classes is correct?

Question 12 options:

A final class cannot have a constructor

A final class cannot have any instances

A final class must have all abstract methods

A final class cannot be extended

Question 13

Which of the following expressions evaluates to false?

class C1 {}

class C2 extends C1 { }

class C3 extends C2 { }

class C4 extends C1 {}

C1 c1 = new C1();

C1 c2 = new C2();

C1 c3 = new C3();

C1 c4 = new C4();

Question 13 options:

c1 instanceof C1

c2 instanceof C1

c4 instanceof C2

c3 instanceof C1

Question 14

Select the correct statement about interfaces and abstract classes among those shown below.

Question 14 options:

No class can implement more than one interface

An abstract class can have ordinary methods but an interface cannot

It is possible to create an instance of an abstract class

An abstract class cannot have any constructors

Question 15

Which of the following declarations are valid?

class Base

{

...

}

interface Spec

{

...

}

class Derived extends Base implements Spec

{

}

Question 15 options:

Spec object4 = new Base();

Derived object2 = new Base();

Derived object5 = new Spec();

Spec object3 = new Derived();

Explanation / Answer

Question 11

Answer: An object of a subclass can be assigned to a reference to its superclass without a type cast.

_____________________________________________________________________

Question 12

Answer: A final class cannot be extended

Explanation: A final class does not have abstract methods. Only an abstract class can have abstract methods.

_____________________________________________________________________

Question 13

Answer: c4 instance of C2

Explanation: From the given options c4 instance of C2 is false.

The class C4 extends C1 which states that all the properties of C1 can be used by C4. So c4 is not an instance of C2.

_____________________________________________________________________

Question 14

Answer: An abstract class can have ordinary methods but an interface cannot."

Explanation: An abstract class can have abstract methods and ordinary methods.

An interface can have ordinary methods.

_____________________________________________________________________

Question 15

Answer: Spec object3 = new Derived();"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote