Predict the output of the following Java Programs
Predict the output of the following Java Programs
1. class Test {
protected int x, y;
}
class Main {
public static void main(String args[]) {
Test t = new Test();
System.out.println(t.x + " " + t.y);
}}
2. class Test {
class Main {
public static void DoPrint(Base o)
{
o.Print();
}
public static void main(String[] args)
{
Base x = new Base();
Base y = new Derived();
Derived z = new Derived();
DoPrint(x);
DoPrint(y);
DoPrint(z);
} }
6. class Point {
protected int x, y;
int x = 10;
public static void main(String[] args)
{
Test t = new Test();
System.out.println(t.x);
}
}
int x = 2;
Test(int i) { x = i; }
public static void main(String[] args)
{
Test t = new Test(5);
System.out.println("x = " + t.x);
}
}
9. class Test1 {
Test1(int x)
{