Assignment Advance Java Programming
Assignment Advance Java Programming
Q1. Explain the Direct Read and Indirect Read of static variables also Explain
the output of the following java code. If there is a compile time error then
explain the reason.
Code 1:
class TestStatic
{
static
{
System.out.println("x="+x);
}
public static void main(String[] args)
{
System.out.println("Hello World!");
}
static int x=10;
}
Code 2:
class TestStatic
{
static
{
m1();
}
static void m1()
{
System.out.println("x="+x);
}
public static void main(String[] args)
{m1();
System.out.println("Hello World!");
}
static int x=10;
}
Q2: Explain the method of Overriding. Also, explain what should be done in the
following code so that it can run successfully.
class A
{
Example 1-
input1=123
input2=582
input3=175