Ask Question
12 February, 00:53

Given the following code:

class C1 {}

class C2 extends C1 { }

class C3 extends C2 { }

class C4 extends C1 {}

C1 c1 = new C1 ();

C2 c2 = new C2 ();

C3 c3 = new C3 ();

C4 c4 = new C4 ();

Which of the following expressions evaluates to false?

c4 instanceof C2

c2 instanceof C1

c3 instanceof C1

c1 instanceof C1

+3
Answers (1)
  1. 12 February, 04:17
    0
    c4 instanceof C2 evaluates to false.

    Explanation:

    As C2 extends C1 so c2 instanceof C1 evaluates to true.

    As C3 extends C2 which then extends C1 so c3 instanceof C1 evaluates to true.

    As the object c1 is an instance of C1 class so c1 instanceof C1.

    Therefore only c4 instanceof C2 evaluates to false.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given the following code: class C1 {} class C2 extends C1 { } class C3 extends C2 { } class C4 extends C1 {} C1 c1 = new C1 (); C2 c2 = new ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers