SlideShare una empresa de Scribd logo
1 de 2
Show the output of running the class Test in the following code lines and Explain why you get
this output.
interface A { void print(); }
class C {}
class B extends C implements A { public void print() { } }
class Test { public static void main(String[] args) {
B b = new B();
if (b instanceof A)
System.out.println("b is an instance of A");
if (b instanceof C)
System.out.println("b is an instance of C");
} }
Solution
OUTPUT
b is an instance of A
b is an instance of C
Explaination
instanceof keyword is a binary operator used to test if an object is a subtype of a given type .
b instanceof A is true because b is the object of class B which implements the interface A
Similarly
b instanceof C is also true because, b is the object of class B which is the subclass for class C.
According to the JAVA API
If the class or interface represented by this Class object is either the same as, or is a superclass
or superinterface of, the class or interface represented by the specified Class parameter, then
the above condition is true

Más contenido relacionado

Similar a Show the output of running the class Test in the following code lines.docx

Keyword of java
Keyword of javaKeyword of java
Keyword of javaJani Harsh
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Udayan Khattry
 
Indicate whether each of the following statements is true or false.docx
Indicate whether each of the following statements is true or false.docxIndicate whether each of the following statements is true or false.docx
Indicate whether each of the following statements is true or false.docxmigdalialyle
 
Session 6_Java Interfaces_Details_Programs.pdf
Session 6_Java Interfaces_Details_Programs.pdfSession 6_Java Interfaces_Details_Programs.pdf
Session 6_Java Interfaces_Details_Programs.pdfTabassumMaktum
 
Session 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .pptSession 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .pptTabassumMaktum
 
Session 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .pptSession 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .pptTabassumMaktum
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guidekrtioplal
 
Constructors.16
Constructors.16Constructors.16
Constructors.16myrajendra
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In JavaManish Sahu
 
Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...JAINAM KAPADIYA
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification QuestionsSpringMockExams
 

Similar a Show the output of running the class Test in the following code lines.docx (20)

Keyword of java
Keyword of javaKeyword of java
Keyword of java
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
Java tutoria part 2
Java tutoria part 2Java tutoria part 2
Java tutoria part 2
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
 
E5
E5E5
E5
 
Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
 
Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
 
Indicate whether each of the following statements is true or false.docx
Indicate whether each of the following statements is true or false.docxIndicate whether each of the following statements is true or false.docx
Indicate whether each of the following statements is true or false.docx
 
Session 6_Java Interfaces_Details_Programs.pdf
Session 6_Java Interfaces_Details_Programs.pdfSession 6_Java Interfaces_Details_Programs.pdf
Session 6_Java Interfaces_Details_Programs.pdf
 
Session 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .pptSession 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .ppt
 
Session 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .pptSession 6_Interfaces in va examples .ppt
Session 6_Interfaces in va examples .ppt
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guide
 
Constructors.16
Constructors.16Constructors.16
Constructors.16
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...
 
‫Chapter3 inheritance
‫Chapter3 inheritance‫Chapter3 inheritance
‫Chapter3 inheritance
 
Second chapter-java
Second chapter-javaSecond chapter-java
Second chapter-java
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification Questions
 
C# Overriding
C# OverridingC# Overriding
C# Overriding
 
Interface in java
Interface in javaInterface in java
Interface in java
 

Más de mmary455

signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docxsignment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docxmmary455
 
Simple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docxSimple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docxmmary455
 
show work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docxshow work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docxmmary455
 
Show the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docxShow the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docxmmary455
 
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docxSolubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docxmmary455
 
Sodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docxSodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docxmmary455
 
Societal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docxSocietal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docxmmary455
 
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docxSoil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docxmmary455
 
Show that the worst-case time complexity for Binary Search is given by.docx
Show that the worst-case time complexity for Binary Search is given by.docxShow that the worst-case time complexity for Binary Search is given by.docx
Show that the worst-case time complexity for Binary Search is given by.docxmmary455
 
Since Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docxSince Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docxmmary455
 
Sinking fund bands- Require the issuer to set aside assets in order r.docx
Sinking fund bands-  Require the issuer to set aside assets in order r.docxSinking fund bands-  Require the issuer to set aside assets in order r.docx
Sinking fund bands- Require the issuer to set aside assets in order r.docxmmary455
 
Simplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docxSimplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docxmmary455
 
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docx
Simplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docxSimplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docx
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docxmmary455
 
Case- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docxCase- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docxmmary455
 
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docxCase 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docxmmary455
 
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docxCase 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docxmmary455
 
Carbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docxCarbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docxmmary455
 
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docxCarbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docxmmary455
 
Carnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docxCarnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docxmmary455
 
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docxCanadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docxmmary455
 

Más de mmary455 (20)

signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docxsignment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
 
Simple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docxSimple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docx
 
show work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docxshow work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docx
 
Show the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docxShow the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docx
 
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docxSolubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
 
Sodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docxSodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docx
 
Societal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docxSocietal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docx
 
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docxSoil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
 
Show that the worst-case time complexity for Binary Search is given by.docx
Show that the worst-case time complexity for Binary Search is given by.docxShow that the worst-case time complexity for Binary Search is given by.docx
Show that the worst-case time complexity for Binary Search is given by.docx
 
Since Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docxSince Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docx
 
Sinking fund bands- Require the issuer to set aside assets in order r.docx
Sinking fund bands-  Require the issuer to set aside assets in order r.docxSinking fund bands-  Require the issuer to set aside assets in order r.docx
Sinking fund bands- Require the issuer to set aside assets in order r.docx
 
Simplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docxSimplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docx
 
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docx
Simplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docxSimplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docx
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docx
 
Case- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docxCase- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docx
 
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docxCase 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
 
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docxCase 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
 
Carbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docxCarbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docx
 
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docxCarbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
 
Carnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docxCarnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docx
 
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docxCanadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
 

Último

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Último (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Show the output of running the class Test in the following code lines.docx

  • 1. Show the output of running the class Test in the following code lines and Explain why you get this output. interface A { void print(); } class C {} class B extends C implements A { public void print() { } } class Test { public static void main(String[] args) { B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); if (b instanceof C) System.out.println("b is an instance of C"); } } Solution OUTPUT b is an instance of A b is an instance of C Explaination instanceof keyword is a binary operator used to test if an object is a subtype of a given type . b instanceof A is true because b is the object of class B which implements the interface A
  • 2. Similarly b instanceof C is also true because, b is the object of class B which is the subclass for class C. According to the JAVA API If the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter, then the above condition is true