Time Remaining :00:00:00

Questions to be answered 10

Advanced Java Aptitude Test - Practical Java Questions And Answers



Question No : 1

public class StringTest {
  public static void main(String[] args) {
    new StringTest().run();
  }

  String getLiteralString() {
    return "555";
  }

  void run() {
    System.out.println("555" == "555" + "");
    System.out.println(getLiteralString() == getLiteralString() + "");
  }
}
What will be the output of above code?

Question No : 2

public class Class1{
    public static void main(String arg[]){    
        System.out.println("main() method");
        System.out.println(Class2.VAL);
        System.out.println(Class2.VAL+100);
    }

}
class Class2{
    final static int VAL=9090;
    static{
        System.out.println("**STATIC BLOCK:"+VAL);
    }
}
What will be the output of above code?

Question No : 3

if ("string1".trim() == "string1".trim()) {
    System.out.print("Equal ");
} else {
    System.out.print("Not Equal ");
}

if ("string1".trim() == "string1 ".trim()) {
    System.out.print("Equal");
} else {
    System.out.print("Not Equal");
}
What will be the output of above code?

Question No : 4

public class ErrorTest {
    public static void main(String[] args) {
        try {
            //Operation that fills the memory
        } catch (OutOfMemoryError ome) {
            System.out.println("OutOfMemoryError=<" + ome + ">");
        } catch (Error err) {
            System.out.println("Error=<" + err + ">");
        } catch (Throwable t) {
            System.out.println("Throwable=<" + t + ">");
        } finally {
            System.out.println("In Finally");
        }
    }
}
What will be the output of above code?

Question No : 5

public static void main(String arg[]) {
    System.out.println(23.53 + 5.88 + 17.64);
    System.out.println(23.53 + 17.64 + 5.88);
}
What will be the output of above code?

Question No : 6

abstract public class TestAbstractClass {
    public static final TestAbstractClass testAbstractClassObject = new TestAbstractClass() {};
    //other codes
}
What is the result of running above code?

Question No : 7

public class Test {
    static public void main(String[] args) {
       Long a = 111L;
       Long b = 111L;
       Long c = 222L;
       Long d = 222L;
       System.out.print((a==b) +"  " + (c==d));
    }
}
What is the output of the above code?

Question No : 8

public class TestJava {

    public static void testMethod(Object x) {
        System.out.println("Java Object");
    }

    public static void testMethod(String x) {
        System.out.println("Java String");
    }
    
    public static void main(String[] args){
        testMethod(null);
    }
}
What is the output of above code?

Question No : 9

public class TestJava {

    public static void testMethod(String x) {
        System.out.println("Java String");
    }
    
    public static void testMethod(Integer x) {
        System.out.println("Java Integer");
    }
	
    public static void main(String[] args){
        testMethod(null);
    }
}
What is the output of above code?

Question No : 10

    public static void main(String[] args){
        System.out.print(5 + 6 + "7 ");
        System.out.print("7" + 8 + 9);
    }
What is the output of above code?


Popular Videos

communication

How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know