1-
public class Chirkut {
Chirkut() {
}
Chirkut(int x,int y) {
x=x;
y=y;
}
public static void main(String... args) {
Chirkut c1 = new Chirkut(20,25);
System.out.println(c1); //Line 1
}
private int x;
private int y;
}
A: Compilation fails
B: Compilation fails due to Line 1
B: Prints 0 0
C: Prints 20 25
D: None of the above
2-
public class Chirkut {
Chirkut() {
}
Chirkut(int x,int y) {
x=x;
y=y;
}
public String toString() {
return x + " " + y;
}
public static void main(String... args) {
Chirkut c1 = new Chirkut(20,25);
System.out.println(c1); //Line 1
}
private int x;
private int y;
}
A: Compilation fails
B: Compilation fails due to Line 1
B: Prints 0 0
C: Prints 20 25
D: Prints Chirkut@2132sda or domething like this
E: None of the above
3-
public class Chirkut {
Chirkut() {
Chirkut(5,10);
}
Chirkut(int x,int y) {
x=x;
y=y;
}
public String toString() {
return x + " " + y;
}
public static void main(String... args) {
Chirkut c1 = new Chirkut();
System.out.println(c1); //Line 1
}
private int x;
private int y;
}
A: Compilation fails
B: Compilation fails due to Line 1
B: Prints 0 0
C: Prints 20 25
D: Prints Chirkut@2132sda or domething like this
E: None of the above
4-
class Chirkut {
public int x;
public Chirkut ( ) {
System.out.println("Chirkut constructor called ");
}
}
class GreatChirkut extends Chirkut{
GreateChirkut(int a,int b) {
saper(a); // Line 1
this.a=a;
this.b=b;
}
private void saper(int a) {
}
public static void main(String... args) {
GreateChirkut gc = new GreateChirkut(5,10); // Line 2
System.out.print(" a = " + gc.a);
System.out.print(" b = " + gc.b);
}
private int a;
private int b;
}
A: Compiler error at Line 2, gc is reserved word for garbage collection.
B: Compiler error due to Line 1, first line of the constructor must be super() or this() not saper(), so compilation fails
C: Prints a = 0 b = 0
D: Prints a = 5 b = 10
E: None of the above
5-
class Chirkut {
public int x;
public Chirkut ( ) {
System.out.println("Chirkut constructor called ");
}
}
class GreatChirkut extends Chirkut {
GreateChirkut(int a,int b) {
this.a=a;
this.b=b;
super(a);
}
private void saper(int a) {
}
public static void main(String... args) {
GreateChirkut gc = new GreateChirkut(5,10); // Line 1
System.out.print(" a = " + gc.a);
System.out.print(" b = " + gc.b);
}
private int a;
private int b;
}
A: Compiler error at Line 2, gc is reserved word for garbage collection.
B: No super constructor found with mathcing argument so compilation fails
C: Compiler error
D: Prints:
Chirkut constructor called
a = 0 b = 0
E: Prints
Chirkut constructor called
a = 5 b = 10
6-
class Chirkut {
public int x;
public Chirkut ( int a ) {
System.out.println("Chirkut constructor called ");
}
}
class GreatChirkut extends Chirkut {
GreateChirkut(int a,int b) {
this.a=a;
this.b=b;
}
private void saper(int a) {
}
public static void main(String... args) {
GreateChirkut gc = new GreateChirkut(5,10); // Line 1
System.out.print(" a = " + gc.a);
System.out.print(" b = " + gc.b);
}
private int a;
private int b;
}
A: Compiler error at Line 2, gc is reserved word for garbage collection.
B: Compiler error
C: Prints:
Chirkut constructor called
a = 0 b = 0
D: Prints
Chirkut constructor called
a = 5 b = 10
E: Prints a = 5 b = 10
7-
class Chirkut {
public int x;
private Chirkut() { System.out.println("Chirkut constructor called!");}
}
class GreatChirkut extends Chirkut {
GreateChirkut(int a,int b) {
this.a=a;
this.b=b;
}
private void saper(int a) {
}
public static void main(String... args) {
GreateChirkut gc = new GreateChirkut(5,10); // Line 1
System.out.print(" a = " + gc.a);
System.out.print(" b = " + gc.b);
}
private int a;
private int b;
}
A: Compiler error at Line 2, gc is reserved word for garbage collection.
B: Compiler error
C: Prints:
Chirkut constructor called
a = 0 b = 0
D: Prints
Chirkut constructor called
a = 5 b = 10
8-
class Chirkut {
public int x;
private Chirkut() { System.out.println("Chirkut constructor called!");}
public Chirkut(int x) {
this.x=x;
}
}
class GreatChirkut extends Chirkut {
GreateChirkut(int a,int b) {
super(a);
this.a=a;
this.b=b;
}
private void saper(int a) {
}
public static void main(String... args) {
GreateChirkut gc = new GreateChirkut(5,10); // Line 1
System.out.print(" a = " + gc.a);
System.out.print(" b = " + gc.b);
}
private int a;
private int b;
}
A: Compiler error at Line 2, gc is reserved word for garbage collection.
B: Compiler error
C: Prints:
Chirkut constructor called
a = 0 b = 0
D: Prints
Chirkut constructor called
a = 5 b = 10
E: Prints a=5 b = 10