M inbox (1.044)-sergz Home l My Sac State Mail-sergiozavala@ g Assignments: CSC2
ID: 3740694 • Letter: M
Question
M inbox (1.044)-sergz Home l My Sac State Mail-sergiozavala@ g Assignments: CSC20 0 Homework # 3 Polymorphism H × Ofile//C/Users/Owner/AppData/Local/Packages/Microsoft MicrosoftEdge 8wekyb3d8bbwe/Tempst Show the output of the following program abstract class Furniture abstract void prnt0:) class Recliner extends Furniture Homework void prnt() System.out.println("I'm a recliner");) class LaZBoy extends Recliner void prnt() System.out.println("I'm a lazboy"); public class furnitureTest2! public static void main(Stringl] args) Furniture [] A = { new Recliner(), new Recliner(), new LaZBoy()); for (int i-0; i3; ++i) Alil.prnt0: 12:52 PM E 3/31/2018 2 Type here to search liedExplanation / Answer
In this program we are using abstraction. So if we call print on Recliner it prints I'm a recliner, if we call print on lazyboy it prints I'm lazy boy
Output :
I'm a recliner
I'm a recliner
I'm a lazyboy
In this program we are just using method overriding. if we call x in class A it is 1. If we call in c it is 2.
A w = new A() -> Now x value is 1
B u = new B() -> Still x value is 1 becuase it extend by A
C v = new C() -> Here x is 2
Output :
1
1
2
Please do asks me if you have any doubts, I ll ping you as soon as possible
In this program we are using abstraction. So if we call print on Recliner it prints I'm a recliner, if we call print on lazyboy it prints I'm lazy boy
Output :
I'm a recliner
I'm a recliner
I'm a lazyboy
In this program we are just using method overriding. if we call x in class A it is 1. If we call in c it is 2.
A w = new A() -> Now x value is 1
B u = new B() -> Still x value is 1 becuase it extend by A
C v = new C() -> Here x is 2
Output :
1
1
2
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.