Java Interview Question
Java Interview Question
JAVA INTERVIEW QUESTION
Q-5. Can we have any other return type than void for main method?
Ans: No, Java class main method can have only void return type for the program
to get successfully executed. Nonetheless , if you absolutely must return a value to at the
completion of main method , you can use System.exit(int status).
Q-6. I want to re-reach and use an object once it has been garbage
collected. How it's possible?
Ans: Once an object has been destroyed by garbage collector, it no longer exists
on the heap and it can't be accessed again. There is no way to reference it again.
Q-10. What’s the variance amid an Abstract Class and Interface in Java?
Ans: The main difference amid an abstract class and interface is that a boundary cans only
own
assertion of public static approaches with no existing application while an abstract class can
have associated with any admittance specifies (i.e. public, private etc.) with or without real
implementation. Additional key variance in the usage of abstract classes and lines is that a
class
which gears an interface must contrivance all the approaches of the interface while a class
which receives from an abstract class doesn’t need execution of all the methods of its
superclass. A class can instrument numerous interfaces but it can spread only one abstract
class.
Q-13.What is enumeration?
Ans. It is an interface you can use to access original data structure from which the
enumeration
is obtain.
Q-14. What's the base class in Java from which all classes are derived?
Ans: java.lang.object.
--Sanjeev Choudhary
(Off Campus Jobs India)