<< < 1 2 3 4 5 6 7 8 9 > >>   Sort: Rank

What is serialization?
What is serialization? Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.
2013-05-17, 2004👍, 0💬

Objects are passed by value or by reference?
Objects are passed by value or by reference? Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object .
2013-05-17, 1887👍, 0💬

Primitive data types are passed by reference or pass by value?
Primitive data types are passed by reference or pass by value? Primitive data types are passed by value.
2013-05-16, 1894👍, 0💬

What type of parameter passing does Java support?
What type of parameter passing does Java support? In Java the arguments are always passed by value .
2013-05-16, 1971👍, 0💬

Can a top level class be private or protected?
Can a top level class be private or protected? No. A top level class can not be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.If a top level class is declared as private the compiler will complain that the "mo...
2013-05-15, 2018👍, 0💬

What is the default value of an object reference declared as an instance variable?
What is the default value of an object reference declared as an instance variable? Null unless we define it explicitly.
2013-05-15, 2096👍, 0💬

What is the difference between declaring a variable and defining a variable?
What is the difference between declaring a variable and defining a variable? In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization. e.g String s; is just a declaration while String s = new String ("abcd"); Or S...
2013-05-14, 1983👍, 0💬

Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?
Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*? No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it's sub...
2013-05-14, 4311👍, 0💬

Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile?
Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile? Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying,can not resolv...
2013-05-13, 2478👍, 0💬

What are different types of inner classes?
What are different types of inner classes? Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and specify the static modifier, the compiler treats the class just like any other top-level class. Any class outside ...
2013-05-13, 1876👍, 0💬

What is Overriding?
What is Overriding? When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the superclass. When the method is invoked for an object of the class, it is the new definition of the method that is calle...
2013-05-10, 1888👍, 0💬

What are Checked and UnChecked Exception?
What are Checked and UnChecked Exception? A checked exception is some subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses. Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOExceptio...
2013-05-10, 1918👍, 0💬

Can I import same package/class twice? Will the JVM load the package twice at runtime?
Can I import same package/class twice? Will the JVM load the package twice at runtime? One can import the same package or same class multiple times. Neither compiler nor JVM complains abt it. And the JVM will internally load the class only once no matter how many times you import the same class.
2013-05-09, 1943👍, 0💬

Do I need to import java.lang package any time? Why ?
Do I need to import java.lang package any time? Why ? No. It is by default loaded internally by the JVM.
2013-05-09, 1909👍, 0💬

Can I have multiple main methods in the same class?
Can I have multiple main methods in the same class? No the program fails to compile. The compiler says that the main method is already defined in the class.
2013-05-08, 1919👍, 0💬

Can an application have multiple classes having main method?
Can an application have multiple classes having main method? Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having ...
2013-05-08, 1920👍, 0💬

What environment variables do I need to set on my machine in order to be able to run Java programs?
What environment variables do I need to set on my machine in order to be able to run Java programs? CLASSPATH and PATH are the two variables.
2013-05-07, 1952👍, 0💬

How can one prove that the array is not null but empty using one line of code?
How can one prove that the array is not null but empty using one line of code? Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.
2013-05-07, 1959👍, 0💬

If I do not provide any arguments on the command line, then the String array of Main method will be empty or null?
If I do not provide any arguments on the command line, then the String array of Main method will be empty or null? It is empty. But not null.
2013-05-06, 2574👍, 0💬

What is the first argument of the String array in main method?
What is the first argument of the String array in main method? The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name.
2013-05-06, 3249👍, 0💬

What if I do not provide the String array as the argument to the method?
What if I do not provide the String array as the argument to the method? Program compiles but throws a runtime error "NoSuchMethodError".
2013-05-03, 2665👍, 0💬

What if I write static public void instead of public static void?
What if I write static public void instead of public static void? Program compiles and runs properly.
2013-05-03, 2139👍, 0💬

What if the static modifier is removed from the signature of the main method?
What if the static modifier is removed from the signature of the main method? Program compiles. But at runtime throws an error "NoSuchMethodError".
2013-05-02, 3149👍, 0💬

What if the main method is declared as private?
What if the main method is declared as private? The program compiles properly but at runtime it will give "Main method not public." message.
2013-05-02, 1982👍, 0💬

<< < 1 2 3 4 5 6 7 8 9 > >>   Sort: Rank