Essay
class InstanceofDemo
{
public static void main(String[] args)
{
Parent object1 = new Parent();
Parent object2 = new Child();
System.out.println("object1 instanceof Parent: "
+ (obj1 instanceof Parent));
System.out.println("object1 instanceof Child: "
+ (obj1 instanceof Child));
System.out.println("object1 instanceof MyInterface: "
+ (obj1 instanceof MyInterface));
System.out.println("object2 instanceof Parent: "
+ (obj2 instanceof Parent));
System.out.println("object2 instanceof Child: "
+ (obj2 instanceof Child));
System.out.println("object2 instanceof MyInterface: "
+ (obj2 instanceof MyInterface));
}
}
The above code defines a parent class (named Parent ), a simple interface (named MyInterface ), and a child class (named Child ) that inherits from the parent and implements the interface.
Following program execution, what will be the output of the six println statements?
Correct Answer:

Verified
Output:
obj1 instanceof Paren...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
obj1 instanceof Paren...
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q38: By convention, a class diagram contains the
Q39: An advantage to making a method _
Q40: When you use the method name with
Q41: You cannot declare a class to be
Q42: public HourlyEmployee(char dept, double rate, int hours)
Q44: You use the keyword _ to achieve
Q45: <img src="https://d2lvgg3v3hfg70.cloudfront.net/TBX9006/.jpg" alt=" Use the above
Q46: What are virtual method calls?
Q47: public class ASuperClass <br>{ <br> public
Q48: Write the statement to create a class