what is the output of the following codes : code 1. class A { { System.out.print(1); } } class B extends A { { System.out.print(2); } } class C extends B { { System.out.print(3); } } public class MainClass { public static void main(String[] args) { C c = new C(); } } code 2 class M { int i; public M(int i) { this.i = i--; } } class N extends M { public N(int i) { super(++i); System.out.println(i); } } public class MainClass { public static void main(String[] args) { N n = new N(26); } } code 3 class M { int i; public M(int i) { this.i = i--; } } class N extends M { public N(int i) { super(++i); System.out.println(i); } } public class MainClass { public static void main(String[] args) { N n = new N(26); } }
what is the output of the following codes :
code 1.
class A
{
{
System.out.print(1);
}
}
class B extends A
{
{
System.out.print(2);
}
}
class C extends B
{
{
System.out.print(3);
}
}
public class MainClass
{
public static void main(String[] args)
{
C c = new C();
}
}
code 2
class M
{
int i;
public M(int i)
{
this.i = i--;
}
}
class N extends M
{
public N(int i)
{
super(++i);
System.out.println(i);
}
}
public class MainClass
{
public static void main(String[] args)
{
N n = new N(26);
}
}
code 3
class M
{
int i;
public M(int i)
{
this.i = i--;
}
}
class N extends M
{
public N(int i)
{
super(++i);
System.out.println(i);
}
}
public class MainClass
{
public static void main(String[] args)
{
N n = new N(26);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps