Question: PLZ help with the following: IN JAVA Given the following code (where the function FunTest() and the main method are inside one class in the

PLZ help with the following: IN JAVA

Given the following code (where the function FunTest() and the main method are inside one class in the same file where classes X, Y and Z are), predict what is the output?

PLZ help with the following: IN JAVA Given the following code (where

class X{ protected int i; public X() { i=10; } private void myfun() { System.out.println("Number 1"); } class Y extends X{ void myfun() { System.out.println("Number 2"); i=20; System.out.println("i is: "+i); } class Z extends Y{ protected void myfun () { System.out.println("Number 3"); i=30; System.out.println("i is: "+i); } public class Q13 { public static void FunTest(Object obj1) Z zl = (Z)objl; zl. myfun(); Y yl = zl; yl.myfun(); } public static void main(String[] args) { Z zobj = new Z(); FunTest(zobj); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!