Infosys Core Java Interview Questions & Answers

  1. Question 1. What Is The Purpose Of Assert Keyword Used In Jdk1.4.x?

    Answer :

    In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.

  2. Question 2. How Will You Get The Platform Dependent Values Like Line Separator, Path Separator, Etc., ?

    Answer :

    Using Sytem.getProperty(…) (line.separator, path.separator, …)

  3. Adv Java Interview Questions

  4. Question 3. What Is Skeleton And Stub? What Is The Purpose Of Those?

    Answer :

    Stub is a client side representation of the server, which takes care of communicating with the remote server. Skeleton is the server side representation. But that is no more in use… it is deprecated long before in JDK.

  5. Question 4. What Is The Final Keyword Denotes?

    Answer :

    final keyword denotes that it is the final implementation for that method or variable or class. You can’t override that method/variable/class any more.

  6. Adv Java Tutorial

  7. Question 5. What Is The Significance Of Listiterator?

    Answer :

    You can iterator back and forth.

  8. J2EE Interview Questions

  9. Question 6. What Is The Major Difference Between Linkedlist And Arraylist?

    Answer :

    LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.

  10. Question 7. What Is Nested Class?

    Answer :

    If all the methods of a inner class is static then it is a nested class.

  11. J2EE Tutorial
    Core Java Interview Questions

  12. Question 8. What Is Inner Class?

    Answer :

    If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.>

  13. Question 9. What Is Composition?

    Answer :

    Holding the reference of the other class within some other class is known as composition.

  14. JSP Interview Questions

  15. Question 10. What Is Aggregation?

    Answer :

    It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.

  16. Core Java Tutorial

  17. Question 11. What Are The Methods In Object?

    Answer :

    clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString

  18. Java-Springs Interview Questions

  19. Question 12. Can You Instantiate The Math Class?

    Answer :

    You can’t instantiate the math class. All the methods in this class are static. And the constructor is not public.

  20. Adv Java Interview Questions

  21. Question 13. What Is Singleton?

    Answer :

    It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class.

    For eg.,

    public class Singleton

    {

    private static final Singleton s = new Singleton();

    private Singleton()

    {

    }

    public static Singleton getInstance()

    {

    return s;

    }

    // all non static methods …

    }

  22. JSP Tutorial

  23. Question 14. What Is Driver Manager?

    Answer :

    The basic service to manage set of JDBC drivers.

  24. Question 15. What Is Class.forname() Does And How It Is Useful?

    Answer :

    It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( “class-instance”.newInstance() ).

  25. JMS(Java Message Service) Interview Questions

  26. Question 16. What Is A Marker Interface?

    Answer :

    An interface with no methods.

    Example: Serializable, Remote, Cloneable

  27. Java-Springs Tutorial

  28. Question 17. What Interface Do You Implement To Do The Sorting?

    Answer :

    Comparable

  29. Java applet Interview Questions

  30. Question 18. What Is The Eligibility For A Object To Get Cloned?

    Answer :

    It must implement the Cloneable interface

  31. J2EE Interview Questions

  32. Question 19. What Is The Purpose Of Abstract Class?

    Answer :

    It is not an instantiable class. It provides the concrete implementation for some/all the methods. So that they can reuse the concrete functionality by inheriting the abstract class.

  33. Java Tutorial

  34. Question 20. What Is The Difference Between Interface And Abstract Class?

    Answer :

    Abstract class defined with methods. Interface will declare only the methods. Abstract classes are very much useful when there is a some functionality across various classes. Interfaces are well suited for the classes which varies in functionality but with the same method signatures.

  35. Java Interview Questions

  36. Question 21. What Do You Mean By Rmi And How It Is Useful?

    Answer :

    RMI is a remote method invocation. Using RMI, you can work with remote object. The function calls are as though you are invoking a local variable. So it gives you a impression that you are working really with a object that resides within your own JVM though it is somewhere.

  37. Question 22. What Is The Protocol Used By Rmi?

    Answer :

    RMI-IIOP

  38. Java 8 Tutorial

  39. Question 23. What Is A Hashcode?

    Answer :

    hashcode value for this object which is unique for every object.

  40. Java 8 Interview Questions

  41. Question 24. What Is A Thread?

    Answer :

    Thread is a block of code which can execute concurrently with other threads in the JVM.

  42. Core Java Interview Questions

  43. Question 25. What Is The Algorithm Used In Thread Scheduling?

    Answer :

    Fixed priority scheduling.

  44. Question 26. What Is Hash-collision In Hashtable And How It Is Handled In Java?

    Answer :

    Two different keys with the same hash value. Two different entries will be kept in a single hash bucket to avoid the collision.

  45. Java Programmer Interview Questions

  46. Question 27. What Are The Different Driver Types Available In Jdbc?

    Answer :

    1. A JDBC-ODBC bridge
    2. A native-API partly Java technology-enabled driver
    3. A net-protocol fully Java technology-enabled driver
    4. A native-protocol fully Java technology-enabled driver For more information.
  47. JSP Interview Questions

  48. Question 28. Is Jdbc-odbc Bridge Multi-threaded?

    Answer :

    No

  49. Question 29. Does The Jdbc-odbc Bridge Support Multiple Concurrent Open Statements Per Connection?

    Answer :

    No

  50. Question 30. What Is The Use Of Serializable?

    Answer :

    To persist the state of an object into any perminant storage device.