//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class V
{
int i ;
static V test()
{
return new V();
}
public static void main(String[] args)
{
V v1 = test();
System.out.println(v1.i);
}
}
23. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class W
{
int i ;
static W test(W w1)
{
W w2 = new W();
w2.i = w1.i;
return w2;
}
public static void main(String[] args)
{
W w1 = new W();
w1.i = 20;
W w2 = test(w1);
System.out.println(w2.i);
}
}
24. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class X
{
int i ;
static void test(X obj1, X obj2)
{
int i = obj1.i;
obj1.i = obj2.i;
obj2.i = i ;
}
public static void main(String[] args)
{
X x1 = new X(), x2 = new X();
x1.i = 10;
x2.i = 20;
test(x1, x2);
System.out.println(x1.i);
System.out.println(x2.i);
}
}