[ Received from Sandesh
Sadhale]
| |
Q: | What are pass by reference and passby value? |
A: | Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed. |
Q: | What is HashMap and Map? |
A: | Map is Interface and Hashmap is class that implements that. |
Q: | Difference between Vector and ArrayList? |
A: | Vector is synchronized whereas arraylist is not. |
Q: | Difference between Swing and Awt? |
A: | AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT. |
Q: | What if the main method is declared as private? | |
A: | The program compiles properly but at runtime it will give "Main method not public." message. | |
Q: | What if the static modifier is removed from the signature of the main method? | |
A: | Program compiles. But at runtime throws an error "NoSuchMethodError". | |
Q: | What if I write static public void instead of public static void? | |
A: | Program compiles and runs properly. | |
Q: | What if I do not provide the String array as the argument to the method? | |
A: | Program compiles but throws a runtime error "NoSuchMethodError". | |
Q: | If I do not provide any arguments on the command line, then the String array of Main method will be empty or null? | |
A: | It is empty. But not null. | |
Q: | What environment variables do I need to set on my machine in order to be able to run Java programs? | |
A: | CLASSPATH and PATH are the two variables. | |
Q: | Can I have multiple main methods in the same class? | |
A: | No the program fails to compile. The compiler says that the main method is already defined in the class. | |
Q: | Do I need to import java.lang package any time? Why ? | |
A: | No. It is by default loaded internally by the JVM. | |
Q: | What is the default value of an object reference declared as an instance variable? | |
A: | null unless we define it explicitly. | |
Q: | What type of parameter passing does Java support? | |
A: | In Java the arguments are always passed by value . | |
Q: | Primitive data types are passed by reference or pass by value? | |
A: | Primitive data types are passed by value. | |
Q: | What is serialization? | |
A: | Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream. | |
Q: | Which methods of Serializable interface should I implement? | |
A: | The serializable interface is an empty interface, it does not contain any methods. So we do not implement any methods. | |
Post a Comment