SlideShare a Scribd company logo
1 of 2
Download to read offline
Use the following code fragments for the next 3 questions. Assume that: . student. Empileves,
and Betired are all child classes of Peraen Student, Employee, and Retired are all child classes of
Person All four classes have different implementations of a method called getMoney Person p1 =
new Person( ); int m1 =p1.getMoney(); // statement 1 Person p2 = new Student (. . .) ; int m2 =
p2.getMoney ( ); // statement2 Person p3; if (m2
Solution
Given :-
Person p1 = new Person ( );
int m1 = p1.getMoney ( ); // statement1
Person p2 = new Student ( );
int m2 = p2.getMoney ( ); // statement2
Person p3;
if(m2 < 100000)
{
p3 = new Employee( );
}
else
{
p3 = new Retired( );
}
int m3 = p3.getMoney ( ); // statement3
Question 50 :-
statement1 :-
Person p1 = new Person ( );
int m1 = p1.getMoney ( ); // statement1
The call to getMoney ( ) in statement1 will invoke the method defined in Person class.
Explanation :-
Non-private Non-static overridden method is executed from current object class.
Question 51 :-
statement2 :-
Person p2 = new Student ( );
int m2 = p2.getMoney ( ); //statement2
The call to getMoney ( ) in statement2 will invoke the method defined in Student class.
Explanation :-
Non-private non-static overridden method is executed from current object class.

More Related Content

More from ARORACOCKERY2111

compare and contrast the morphology of Cestodes, Trematodes, and Nem.pdf
compare and contrast the morphology of Cestodes, Trematodes, and Nem.pdfcompare and contrast the morphology of Cestodes, Trematodes, and Nem.pdf
compare and contrast the morphology of Cestodes, Trematodes, and Nem.pdf
ARORACOCKERY2111
 
An important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdfAn important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdf
ARORACOCKERY2111
 
Alternate Electron acceptors Know what these electron acceptors will.pdf
Alternate Electron acceptors Know what these electron acceptors will.pdfAlternate Electron acceptors Know what these electron acceptors will.pdf
Alternate Electron acceptors Know what these electron acceptors will.pdf
ARORACOCKERY2111
 
You have been exposed to each of the 8 microbes below.After a coup.pdf
You have been exposed to each of the 8 microbes below.After a coup.pdfYou have been exposed to each of the 8 microbes below.After a coup.pdf
You have been exposed to each of the 8 microbes below.After a coup.pdf
ARORACOCKERY2111
 
Which statement below regarding membrane structure and membrane tran.pdf
Which statement below regarding membrane structure and membrane tran.pdfWhich statement below regarding membrane structure and membrane tran.pdf
Which statement below regarding membrane structure and membrane tran.pdf
ARORACOCKERY2111
 
what steps can be taken to prevent a core melt down when the tur.pdf
what steps can be taken to prevent a core melt down when the tur.pdfwhat steps can be taken to prevent a core melt down when the tur.pdf
what steps can be taken to prevent a core melt down when the tur.pdf
ARORACOCKERY2111
 
Think about immigrant and refugee groups in your community. What is .pdf
Think about immigrant and refugee groups in your community. What is .pdfThink about immigrant and refugee groups in your community. What is .pdf
Think about immigrant and refugee groups in your community. What is .pdf
ARORACOCKERY2111
 
The situation at Good Health Hospital has become a bit overwhelming .pdf
The situation at Good Health Hospital has become a bit overwhelming .pdfThe situation at Good Health Hospital has become a bit overwhelming .pdf
The situation at Good Health Hospital has become a bit overwhelming .pdf
ARORACOCKERY2111
 

More from ARORACOCKERY2111 (20)

Describe the purpose for carrying out a DNAase Hypersensitivity assa.pdf
Describe the purpose for carrying out a DNAase Hypersensitivity assa.pdfDescribe the purpose for carrying out a DNAase Hypersensitivity assa.pdf
Describe the purpose for carrying out a DNAase Hypersensitivity assa.pdf
 
compare and contrast the morphology of Cestodes, Trematodes, and Nem.pdf
compare and contrast the morphology of Cestodes, Trematodes, and Nem.pdfcompare and contrast the morphology of Cestodes, Trematodes, and Nem.pdf
compare and contrast the morphology of Cestodes, Trematodes, and Nem.pdf
 
Carbon dioxide transport Drag each label to the appropriate location.pdf
Carbon dioxide transport  Drag each label to the appropriate location.pdfCarbon dioxide transport  Drag each label to the appropriate location.pdf
Carbon dioxide transport Drag each label to the appropriate location.pdf
 
An important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdfAn important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdf
 
Assume ND=NA=1E+15cm-3, in two different slabs of semiconductor (1 e.pdf
Assume ND=NA=1E+15cm-3, in two different slabs of semiconductor (1 e.pdfAssume ND=NA=1E+15cm-3, in two different slabs of semiconductor (1 e.pdf
Assume ND=NA=1E+15cm-3, in two different slabs of semiconductor (1 e.pdf
 
Alternate Electron acceptors Know what these electron acceptors will.pdf
Alternate Electron acceptors Know what these electron acceptors will.pdfAlternate Electron acceptors Know what these electron acceptors will.pdf
Alternate Electron acceptors Know what these electron acceptors will.pdf
 
A man with blood type A and a woman with blood type B have three chi.pdf
A man with blood type A and a woman with blood type B have three chi.pdfA man with blood type A and a woman with blood type B have three chi.pdf
A man with blood type A and a woman with blood type B have three chi.pdf
 
You have been exposed to each of the 8 microbes below.After a coup.pdf
You have been exposed to each of the 8 microbes below.After a coup.pdfYou have been exposed to each of the 8 microbes below.After a coup.pdf
You have been exposed to each of the 8 microbes below.After a coup.pdf
 
Which of the four levels of measurement is most appropriate for Wei.pdf
Which of the four levels of measurement is most appropriate for Wei.pdfWhich of the four levels of measurement is most appropriate for Wei.pdf
Which of the four levels of measurement is most appropriate for Wei.pdf
 
Which statement below regarding membrane structure and membrane tran.pdf
Which statement below regarding membrane structure and membrane tran.pdfWhich statement below regarding membrane structure and membrane tran.pdf
Which statement below regarding membrane structure and membrane tran.pdf
 
Why do cyanobacteria possess heterocystsA- Heterocysts shield the.pdf
Why do cyanobacteria possess heterocystsA- Heterocysts shield the.pdfWhy do cyanobacteria possess heterocystsA- Heterocysts shield the.pdf
Why do cyanobacteria possess heterocystsA- Heterocysts shield the.pdf
 
Which of the following isare true regarding hex digitsA. Hex dig.pdf
Which of the following isare true regarding hex digitsA. Hex dig.pdfWhich of the following isare true regarding hex digitsA. Hex dig.pdf
Which of the following isare true regarding hex digitsA. Hex dig.pdf
 
which is true of the data shown in the histogramI. The distributi.pdf
which is true of the data shown in the histogramI. The distributi.pdfwhich is true of the data shown in the histogramI. The distributi.pdf
which is true of the data shown in the histogramI. The distributi.pdf
 
what steps can be taken to prevent a core melt down when the tur.pdf
what steps can be taken to prevent a core melt down when the tur.pdfwhat steps can be taken to prevent a core melt down when the tur.pdf
what steps can be taken to prevent a core melt down when the tur.pdf
 
use properties of logarithms to expand the logarithmic expression as.pdf
use properties of logarithms to expand the logarithmic expression as.pdfuse properties of logarithms to expand the logarithmic expression as.pdf
use properties of logarithms to expand the logarithmic expression as.pdf
 
Think about immigrant and refugee groups in your community. What is .pdf
Think about immigrant and refugee groups in your community. What is .pdfThink about immigrant and refugee groups in your community. What is .pdf
Think about immigrant and refugee groups in your community. What is .pdf
 
This is for subject MicrobiologyDifferentiate between physical and.pdf
This is for subject MicrobiologyDifferentiate between physical and.pdfThis is for subject MicrobiologyDifferentiate between physical and.pdf
This is for subject MicrobiologyDifferentiate between physical and.pdf
 
The situation at Good Health Hospital has become a bit overwhelming .pdf
The situation at Good Health Hospital has become a bit overwhelming .pdfThe situation at Good Health Hospital has become a bit overwhelming .pdf
The situation at Good Health Hospital has become a bit overwhelming .pdf
 
The law of large numbers states that as the number of observations .pdf
The law of large numbers states that as the number of  observations .pdfThe law of large numbers states that as the number of  observations .pdf
The law of large numbers states that as the number of observations .pdf
 
The majority of new cancers are due to inherited DNA defects. True Fa.pdf
The majority of new cancers are due to inherited DNA defects. True Fa.pdfThe majority of new cancers are due to inherited DNA defects. True Fa.pdf
The majority of new cancers are due to inherited DNA defects. True Fa.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

Use the following code fragments for the next 3 questions. Assume tha.pdf

  • 1. Use the following code fragments for the next 3 questions. Assume that: . student. Empileves, and Betired are all child classes of Peraen Student, Employee, and Retired are all child classes of Person All four classes have different implementations of a method called getMoney Person p1 = new Person( ); int m1 =p1.getMoney(); // statement 1 Person p2 = new Student (. . .) ; int m2 = p2.getMoney ( ); // statement2 Person p3; if (m2 Solution Given :- Person p1 = new Person ( ); int m1 = p1.getMoney ( ); // statement1 Person p2 = new Student ( ); int m2 = p2.getMoney ( ); // statement2 Person p3; if(m2 < 100000) { p3 = new Employee( ); } else { p3 = new Retired( ); } int m3 = p3.getMoney ( ); // statement3 Question 50 :- statement1 :- Person p1 = new Person ( ); int m1 = p1.getMoney ( ); // statement1 The call to getMoney ( ) in statement1 will invoke the method defined in Person class. Explanation :- Non-private Non-static overridden method is executed from current object class. Question 51 :- statement2 :- Person p2 = new Student ( ); int m2 = p2.getMoney ( ); //statement2 The call to getMoney ( ) in statement2 will invoke the method defined in Student class. Explanation :-
  • 2. Non-private non-static overridden method is executed from current object class.