-
What is the difference between static and non-static variables
A static variable is associated with the class as a whole rather than with specific instancesof a class. Non-static variables take on unique values with each object instance.
-
What is the difference between a break statement and a continue statement
A break statement results in the termination of the statement to which it applies (switch,for, do, or while). A continue statement is used to end the current loop iteration andreturn control to the loop statement.
-
-
-
-
-
What are the main differences between Java and C++?
Everything is an object in Java (Single root hierarchy as everything gets derived from java.lang.Object). Java does not have all the complicated aspects of C++ ( For ex: Pointers, templates, unions, operator overloading, structures etc..) The Java language promoters initially said "No pointers!", but when many programmers questioned how you can work without pointers, the promoters began saying "Restricted...
-
-
Predict the output of the given code:
javapublic class Test {
private static String msg = "HCL ";
static{
Thread t = new Thread(new Runnable(){
public void run(){
msg = "Technologies ";
}
});
t.start();
}
public static void main(String[] args){
System.out.print(msg);
}}
a) Compiles and prints HCL
b) Compiles and prints Technologies
c) Compiles and... -
An interface contains _________ methods
Skill/Topic: InheritanceA) AbstractB) Non-abstract C) Implemented D) Un-implemented
-
What is a transient variable
A transient variable is a variable that may not be serialized.
Java Interview Questions
Ans