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?
What will be an ideal response?
Output:
obj1 instanceof Parent: true
obj1 instanceof Child: false
obj1 instanceof MyInterface: false
obj2 instanceof Parent: true
obj2 instanceof Child: true
obj2 instanceof MyInterface: true
You might also like to view...
Which of the following JavaScript expressions is equivalent to the given HTML code? ?
When Excel recognizes that another user has modified a shared workbook, Excel displays a dialog box indicating that the workbook has been updated with changes saved by other users.
Answer the following statement true (T) or false (F)
In order to retrieve logs from exchange, the PowerShell cmdlet _______________________ can be used.?
A. ?GetExchangeLogs.ps1 B. ?GetLogInfo.ps1 C. ?ShowExchangeHistory.ps1 D. ?GetTransactionLogStats.ps1
_________ representation is when the radix point is fixed and assumed to be to the right of the rightmost digit.
Fill in the blank(s) with the appropriate word(s).