Technical Question Bank: Java Basics

Review the fundamentals of Java to ace your technical interview well. The purpose of technical interviews is to check the field-specific knowledge of the candidates. These interviews are held for specialist   or technical job positions.
 
List of Technical Questions based on Java Basics
  • Differentiate between a constructor and a method?
  • What is the purpose of garbage collection in Java? When is it used?
  • Describe synchronization in respect to multithreading
  • What is an abstract class?
  • Differentiate between an Interface and an Abstract class?
  • What is a different way of using thread?
  • What is an Iterator?
  • State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.
  • What is static in java?
  • What is final class?
  • What if the main() method is declared as private?
  • What if the static modifier is removed from the signature of the main() method?
  • What difference does it make if I write static public void instead of public static void?
  • What if I do not provide the String array as the argument to the method?
  • What is the first argument of the String array in main() method?
  • If I do not provide any arguments on the command line, then the will the String array of main()method be empty or null?
  • Using one line of code, how can it be proved that the array is not null but empty?
  • What all environment variables do I need to set on my system in order to be able to run Java programs?
  • Can we have an application that has multiple classes having main() method?
  • Can we have multiple main() methods in the same class?
  • Do I need to import java lang package any time? Why?
  • Can I import the same package/class twice? Will the JVM load the package twice at runtime?
  • Explain Checked and UnChecked Exception?
  • What is Overriding?
  • At compile time, are the imports checked for validity? Example: will the code containing an import such as java.lang.ABCD compile?
  • Does importing a package import the subpackages as well? Example: Does importing com.MyTest.*
  • also import com.MyTest.UnitTests.*?
  • Differentiate between declaring a variable and defining a variable.
  • What is the default value of an object reference declared as an instance variable?
  • Can we make a top level class private or protected?
  • What type of parameter passing does Java support?
  • Primitive data types are passed by reference or passed by value?
  • Objects are passed by value or by reference?
  • Explain serialization?
  • How do I serialize an object to a file?
  • Which methods of Serializable interface should I implement?
  • How can I customize the seralization process? i.e. how can one have a control over the serialization process?
  • What is the common usage of serialization?
  • What is an Externalizable interface?
  • What happens to the object references included in the object when you serialize an object?
  • What should one take care of while serializing the object?
  • What happens to the static fields of a class during serialization?
  • Does Java provide any construct to find out the size of an object?
  • What are wrapper classes?
  • Why wrapper classes required?
  • What are checked exceptions?
  • What are runtime exceptions?
  • What is the difference between an error and an exception?
  • How do you create custom exceptions?
  • What should I do if I want an object of my class to be thrown as an exception object?
  • If my class already extends from some other class then what should I do if I want an instance of my class to be thrown as an exception object?
  • How does an exception permeate through the code?
  • Explain the different ways to handle exceptions?
  • Is it necessary that each try block be followed by a catch block?
  • If I write return at the end of the try block, will the finally block still execute?
  • If I write System.exit(0); at the end of the try block, will the finally block still execute?
  • How are Observer and Observable used?
  • What is synchronization? Why is it important?
  • How does Java handle integer overflows and underflows?
  • Does garbage collection guarantee that a program will not run out of memory?
  • Differentiate between preemptive scheduling and time slicing?
  • What is the initial state of a thread when it is created and started?
  • What is the purpose of finalization?
  • What is the significance of Locale class?
  • Differentiate between a while statement and a do statement?
  • Differentiate between static and non-static variables?
  • How are this() and super() used with constructors?
  • What is daemon thread and which method is used to create the daemon thread?
  • Can applets communicate with each other?
  • Explain the steps in the JDBC connection.
  • How does a try statement determine which catch clause should be used to handle an exception?
  • Can an unreachable object become reachable again?
  • What method must be implemented by all threads?
  • What are synchronized methods and synchronized statements?
  • What modifiers are allowed for methods in an Interface?
  • Mention some alternatives to inheritance.
  • What do we mean when we say that a method or field is "static"?
  • Differentiate between preemptive scheduling and time slicing.
  • What is the catch or declare rule for method declarations?
  • Is Empty java file a valid source file?
  • Can a java file contain more than one java classes?
  • Is String a primitive data type in Java?
  • Is main a keyword in Java?
  • Is next a keyword in Java?
  • Is delete a keyword in Java?
  • Is exit a keyword in Java?
  • What happens if you do not initialize an instance variable of any of the primitive types in Java?
  • What will be the initial value of an object reference which is defined as an instance variable?
  • Elaborate the different scopes for Java variables?
  • What is the default value of the local variables?
  • How many objects are created in the following piece of code?
    MyClass c1, c2, c3;
    c1 = new MyClass ();
    c3 = new MyClass ();
  • Can a public class MyClass be defined in a source file named YourClass.java?
  • Can main() method be declared final?
  • What is Hash Map and Map?
  • Differentiate between Hash Map and Hash Table.
  • Differentiate between Vector and Array List.
  • Differentiate between Swing and Awt.
  • What will be the default values of all the elements of an array that are defined as an instance variable?
If you have any question, suggestion or feedback, feel free to post it in the discussion box given below.
Rate Us
Views:10816