Ques:
What if the main method is declared as private?
What if the main method is declared as private?
Ans:
The program compiles properly but at runtime it will give “Main method not public.” message
The program compiles properly but at runtime it will give “Main method not public.” message
************************************************************************************
Ques:
What is meant by pass by reference and pass by value in Java?
Ques:
What is meant by pass by reference and pass by value in Java?
Ans:
Pass by reference means, passing the address itself rather than passing the value. Pass by value means passing a copy of the value.
Pass by reference means, passing the address itself rather than passing the value. Pass by value means passing a copy of the value.
************************************************************************************
Ques: What gives java it’s “write once and run anywhere” nature?
Ans : All Java programs are compiled into class files that contain bytecodes. These byte codes can be run in any platform and hence java is said to be platform independent.
************************************************************************************
Ans:
In System.out.println(), what is System, out and println?
Explain the Polymorphism?
Ans:
Polymorphism in simple terms means one name many forms.
Polymorphism exists in three distinct forms in Java:
Ques: What if the static modifier is removed from the signature of the main method?
(OR)
Ques: What if I do not provide the String array as the argument to the method?
Program compiles. But at runtime throws an error “NoSuchMethodError”.
************************************************************************************
Ques: What is final, finalize() and finally?
Ans:
o final - declare constant
o finally - handles exception
o finalize - helps in garbage collection
o finally - handles exception
o finalize - helps in garbage collection
Final:
A final class can’t be extended i.e., final class may not be subclassed. This is done for security reasons with basic classes like String and Integer.
A final method can’t be overridden when its class is inherited. You can’t change value of a final variable (is a constant)
Finalize():
finalize() method is used just before an object is destroyed and garbage collected.
Finally:
Finally, a key word used in exception handling and will be executed whether or not an exception is thrown. For Ex..C
losing of open connections is done in the finally method
************************************************************************************
Ques:What is the GregorianCalendar class?
Ans:
The GregorianCalendar provides support for traditional Western calendars
************************************************************************************
Ques:Is sizeof a keyword in java?
Ans:
The sizeof operator is not a keyword.
************************************************************************************
Ques:
What is a native method? Ans:
A native method is a method that is implemented in a language other than Java
************************************************************************************
Ques:Ans:
System is a predefined final class, out is a PrintStream object and println is a built-in overloaded method in the out object.
************************************************************************************
Ques:Ans:
Polymorphism in simple terms means one name many forms.
Polymorphism exists in three distinct forms in Java:
• Method overloadingdsdsad
• Method overriding through inheritance
• Method overriding through the Java interface
• Method overriding through inheritance
• Method overriding through the Java interface
***************************************************************************************
