Menu
Topics Index
...
`

instanceof test


If you need explanation Read this topic

If you need Answer Take test on this topic

instanceof test
import java.awt.Component;
public class Ticker extends Component {
    public static void main(String[] args) {
        Ticker t = new Ticker();
        /* Missing Statements ? */
    }
}
Which two of the following statements, inserted independently, could legally be inserted into missing section of this code?
1. boolean test = (Component instanceof t);
2. boolean test = (t instanceof Ticker);
3. boolean test = t.instanceof(Ticker);
4. boolean test = (t instanceof Component);

A. 2 and 3
B. 2 and 4
C. 1 and 4
D. 1 and 3
E. None of the above
Topic: Advanced Java Programming Concepts

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

B

Posted by Zeg Abder    2014-07-24 09:19:42


b

Posted by Mohd Naveed    2014-07-24 09:20:13


b because An object of subclass type is also a type of parent class and other is a simple implementation of instance of operator

Posted by Mohd Naveed    2014-07-24 09:21:06


B

Posted by Himani Mittal    2014-07-24 09:30:34


© meritcampus 2019

All Rights Reserved.

Open In App