1. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class A
{
int i;
}
class Manager1 // All object class methods available
{
public static void main (String[] args)
{
A a1 = new A();
a1.i = 10;
A a2 = new A();
a2.i = 20;
System.out.println(a1); // internaly toString method is called
System.out.println(a2);
}
}
2. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class B
{
int i;
}
class Manager2
{
public static void main (String[] args)
{
B b1 = new B();
b1.i = 10;
String s1 = b1.toString();
System.out.println(b1);
System.out.println(s1);
}
}
3. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class C
{
int i;
C(int i)
{
this.i = i;
}
}
class Manager3
{
public static void main (String[] args)
{
C c1 = new C(90);
String s1 = c1.toString();
String s2 = "address:" + c1;
System.out.println(c1); // internaly toString method is called
System.out.println(s1);
System.out.println(s2);
}
}
4. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class D
{
}
class Manager4
{
public static void main (String[] args)
{
D d1 = new D();
D d2 = d1;
System.out.println(d1);
System.out.println(d2);
}
}