Menu
Topics Index
...
`

Cat Rat Mat Bat Hat


If you need explanation Read this topic

If you need Answer Take test on this topic

Cat Rat Mat Bat Hat
What lines in the following program has compilation errors?
public class CatRatMatBatHat {
    public static void main(String[] args) {
        Cat cat = new Cat(); /* LINE A */
        Rat rat = new Rat(); /* LINE B */
        Hat hat = new Hat(); /* LINE C */
        Mat mat = new Mat(); /* LINE D */
        Bat bat = new Bat(); /* LINE E */
        cat = mat; /* LINE F */
        rat = mat; /* LINE G */
        bat = rat; /* LINE H */
        hat = bat; /* LINE I */
        mat = hat; /* LINE J */
        bat = mat; /* LINE K */
    }
}

interface Cat {}
class Rat {}
interface Hat {}
class Mat extends Bat implements Cat {}
class Bat extends Rat implements Cat, Hat {}

A. A, B, C, D
B. B, D, E, F, G
C. A, C, D, H, I, J
D. A, C, H, J
E. A, C, F, H, J
Topic: Creating Interface In Java With Example Program

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans : A

Posted by Sapparapu Pradeep Kumar    2014-06-24 09:06:37


Ans is D. instances cant be created for interfaces, so lines A and C give errors. At line H and J incompatible types error occurs.

Posted by Nikhil Sulibhavi    2014-06-24 09:10:17


Ans C cannot create objects for interfaces and cannot extend class which are used first and then declared like mat class is extending bat class

Posted by Vicky Maduri    2014-06-24 09:19:38


ANS IS E
--A&C  because You can never instantiate an interface in java.
--F,H&J as objects of interfaces are referred at that statements which can never be created.

Posted by Mânïshå Mùlchåndânï    2014-06-24 09:20:54


Ans is c instance of A and C cannot be created because A and c are interface whose which r used for define standard  D,H,I,J gives errors because class does  Mat cnt extends class bat before declare so mat class not create statement related to Mat give error

Posted by Dinesh Saini    2014-06-24 11:30:59


Congratulations Nikhil Sulibhavi. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-06-25 04:06:51


© meritcampus 2019

All Rights Reserved.

Open In App