Multiple choice

Find the output of the following program code. class parent {
final int a=10;
void meth() {
System.out.println(parent); } } class Test1 extends parent { int a=20;
public static void main(String[] args)
{ parent par = new parent(); parent par2 = new Test1(); par.meth(); par2.meth(); System.out.println(par.a); System.out.println(par2.a); } void meth() { System.out.println(child);
}
}

  1. parentchild1010

  2. parentchild 2020

  3. child child2020

  4. parentparent 2020

  5. childchild1010

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

par is the object of parent class so it will call meth() method of parent class, par2 will call the mothod of Test1 class due to overriding but the variable will call only of Parent class because overriding is for methods not for variable