Multiple choice

What is the output of the following program? import java.io.*; class sample2 { int a; static int b; sample2() { a=0; b=10; } sample2(int a,int b) { this.a=a; this.b=b; } public void test() { System.out.print(a); System.out.print(b); } public static void main(String args[]) {sample2 ob=new sample2(); System.out.print(ob.a); System.out.print(ob.b); sample2 ob1=new sample2(4,5); System.out.print(ob1.a); System.out.print(ob1.b); test(); } }

  1. 01045010

  2. 0104505

  3. 0104545

  4. error:non static object cannot be referenced from static context

  5. 01045

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

It is the correct choice as it has to create call through object like ob1.test(), without which it is creating an error.