Computer Science, asked by sharathsolo3, 8 months ago

Write the output of the following program?
class Test{
int a = 10
static int b=20;
public static void main(String[] args)
{
Test t1 = new Test();
t1.a = 100
t1.b = 200
Test t2 = new Test();
System.out.println("t1.a =" +t1.a +"t1.b =" + t1.b);
System.out.println("12. a =" + t2.a + "12.b =" + t2.b),​

Answers

Answered by kovidhkapoor5
2

Answer:

A) t1.a=100 t1.b=200

t2.a=10 t2.b=200

Explanation:

static variable is class level variable. If we create multiple objects of class and all objects can point same reference of static variable means If you can change the value of static variable in any object, then compiler automatically updates the value of all object static variables.

Similar questions