KyaPoocha.com

Huge Collection of Interview Questions


Archive for September, 2006

Can main method be declared final? 

Yes, the main method can be declared final, in addition to being public static.  Read more »

Can a public class MyClass be defined in a source file named YourClass.java? 

No the source file name, if it contains a public class, must be the same as the public class name itself with a .java extension.  Read more »

What is the default value of the local variables? 

The local variables are not initialized to any default value, neither primitives nor object references. If you try to use these variables without initializing them... Read more »

What are the different scopes for Java variables? 

The scope of a Java variable is determined by the context in which the variable is declared. Thus a java variable can have one of the three scopes at any given point... Read more »

What will be the initial value of an object reference which is defined as an instance variable? 

The object references are all initialized to null in Java. However in order to do anything useful with these references, you must set them to a valid object, else... Read more »

What happens if you dont initialize an instance variable of any of the primitive types in Java? 

Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0, a boolean will be initialized to false.  Read more »

Are main, next delete, exit keywords in Java? 

No, they are not keywords in Java. delete is not a keyword in Java. Java does not make use of explicit destructors the way C++ does. To exit a program explicitly... Read more »

Is String a primitive data type in Java? 

No String is not a primitive data type in Java, even though it is one of the most extensively used object. Strings in Java are instances of String class defined... Read more »

Can a .java file contain more than one java classes? 

Yes, a .java file contain more than one java classes, provided at the most one of them is a public class.  Read more »

Is Empty.java file a valid source file? 

Yes, an empty .java file is a perfectly valid source file.  Read more »

What does it mean that a method or field is “static”? 

Static variables and methods are instantiated only once per class. In other words they are class variables, not instance variables. If you change the value of a... Read more »

What modifiers are allowed for methods in an Interface? 

Only public and abstract modifiers are allowed for methods in interfaces.  Read more »

What is Externalizable? 

Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput... Read more »

What method must be implemented by all threads? 

All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.  Read more »

What are synchronized methods and synchronized statements? 

Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the... Read more »

Page 1 of 812345»...Last »