Menu
Question Index
...

What will be the output of the following program?

public class Write extends Read {
    static Learn parent;
    static Write child;
    public static void main(String args[]) {
        Write parent = new Write();
        Write child = new Write();
        System.out.println(checkBool1(parent instanceof Learn));
        System.out.println(checkBool2(parent instanceof Write));
        System.out.println(checkBool3(child instanceof Learn));
    }
    private static boolean checkBool1(boolean b1) {
        return parent instanceof Learn;
    }
    private static boolean checkBool2(boolean b2) {
        return child instanceof Learn;
    }
    public static boolean checkBool3(boolean b3) {
        return parent instanceof Write;
    }
}
interface Learn {    }
class Read implements Learn {    }


true
true
true
true
false
true
false
true
false
false
false
false
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App