Show the output of the following program abstract class Furn
Show the output of the following program. abstract class Furniture {abstract void pmt();} class Rediner extends Furniture {void prnt() {System, out.println(\"I\'m a recliner\");}} class LaZBoy extends Rediner {void prnt() {System.out.println(\"I\'m a lazboy\");}} public class furnitureTest2 {public static void mam(String[] args) {Furniture [] A = {new Recliner(), new Recliner(), new LaZBoy()}; for(int i=0; i
Solution
Answer is :
I\'m a recliner
I\'m a recliner
I\'m a lazboy
Explaination:
the main heart of the code is
Furniture [] A = { new Recliner(), new Recliner(), new LaZBoy()};
where array A contains object for Recliner and LaZBoy
A[0] == object of Recliner()
A[1] == object of Recliner()
A[2] == object of LaZBoy()
Prints the object
for (int i=0; i<3; ++i)
A[i].prnt();
so for each A it call prnt() function of their respective classes ..
for the first 2 times it call Recliner()\'s prnt()
3rd time it call lazboy()\'s prnt()
