Compaq Placement Paper For Freshers Part-3
21) What is the difference between instanceof() and isInstance()?
instanceof() is used to see whether the object can be typecast without making use of the exception.
isInstance() is to check whether the specified object is compatible with the class that represent the object.
22) How can you achieve multiple inheritance in java?
Multiple inheritance in java implemented in similar to the C++ with one difference the inherited interface should be abstract.
23) What is the difference between == and equals methods?
‘==’ is used to check whether two numbers are equal
‘Equals’ is used to check whether two strings are equal.
24) What are java beans?
Java bean is a platform independent and portable. It helps to develop code that is possible to run in any environment
25) What is RMI?
RMI stands for remote method invocation; it enables the developer to create application based on java, in which the java objects are invoked by java virtual machine.s
26) How does a try statement determine which catch clause should be used to handle an exception?
When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.
27) Is Empty .java file a valid source file?
An empty java file is perfectly a valid java source file.
28) Is delete a keyword in Java?
Delete is not a keyword in Java. Java does not make use of explicit destructors the way C++ does.
29) How many objects are created in the following piece of code?
MyClass c1, c2, c3;
c1 = new MyClass ();
c3 = new MyClass ();
c1 and c3 are the two objects created. The c2 is only declared and not initialized.
30) What will be the output of the following statement?
System.out.println (“1” + 5);