Tag: programming languages

Questions Related to programming languages

What is the output of following Program class C{ static int f1(int i) { System.out.print(i + ","); return 0; } public static void main (String[] args) { int i = 0; i = i++ + f1(i); System.out.print(i); } }

  1. Prints: 0,0

  2. Prints: 1,0

  3. Prints: 0,1

  4. Compile-time error


Correct Option: B

class c1{ public static void main(String a[]) { c1 ob1=new c1(); Object ob2=ob1; System.out.println(ob2 instanceof Object); System.out.println(ob2 instanceof c1); } } What is the result of attempting to compile and run the program?

  1. Prints true,false

  2. Print false,true

  3. Prints true,true

  4. compile time error


Correct Option: C
  1. Compile failure

  2. sucessfully compiled, but through exception in run time.

  3. It runs sucessfuly and prints "without the main method"

  4. It runs sucessfuly, but No output.


Correct Option: C