Java Aptitude

Java OCJP

OCJP Practice MCQ 2

  1. Guess the output:

    public class HelloWorld {
    
     public static void main(String argv[]) {
      int $7;
      
      System.out.println($7);
     }
    }
    
    
     

    A.

    B.

    C.

    D.

  2. Read the below code-snippet

    public class Test {
    
          int num;
          boolean isTrue;
          static int num1;
    
          public void printValue() {
    
                System.out.print(num);
                System.out.print(isTrue);
                System.out.print(num1);
          }
    }
    
    class HelloWorld{
    
          public static void main(String argv[]) {
                Test test= new Test();
                test.printValue();
          }
    }

    Guess the Output?

     

    A.

    B.

    C.

    D.


Please Share this page