Menu
Question Index
...

What will be the output of the following program?

public class LovePureImpure {
    static {
        System.out.println("Love is neither pure nor impure");
    }
    public LovePureImpure() {
        System.out.println("Love is purely impure and impurely pure");
    }
    public static void main(String[] args) {
        Pure pure = null;
        Impure impure = new Impure();
        pure = new Pure();
    }
}
class Pure {
    static {
        System.out.println("I am pure Love");
    }
    public Pure() {
        System.out.println("I am impure Love disguised as pure Love");
    }
}
class Impure {
    public Impure() {
        System.out.println("I am impure Love");
    }
}


Love is neither pure nor impure
I am pure Love
I am impure Love disguised as pure Love
I am impure Love
I am impure Love disguised as pure Love
Love is neither pure nor impure
I am impure Love
I am pure Love
I am impure Love disguised as pure Love
Love is neither pure nor impure
Love is purely impure and impurely pure
I am impure Love
I am pure Love
I am impure Love disguised as pure Love
Some other output or Compilation Error or Runtime Error

Doubts

Problems

Topic: Creating Static Methods In Java Using Static Keyword

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App