1. Q. What is the difference between a function and a method?
      A. A method is a function that is written in a class. We do not have functions in java; instead we have methods. This means whenever a function is written in java, it should be written inside the class only. But if we take C++, we can write the functions inside as well as outside the class. So in C++, they are called member functions and not methods.
    2. Q. What is an API document?
      A.An API document is a .html file that contains description of all the features of a software, a product, or a technology. API document is helpful for the user to understand how to use the software or technology.
    3. Q. What is the difference between #include and import statement?
      A.#include directive makes the compiler go to the C/C++ standard library and copy the code from the header files into the program. As a result, the program size increases, thus wasting memory and processor’s time. import statement makes the JVM go to the Java standard library, execute the code there , and substitute the result into the program. Here, no code is copied and hence no waste of memory or processor’s time. so import is an efficient mechanism than #include.
    4. Q. What is the difference between print() and println() method ?
      A.Both methods are used to display the results on the monitor.print() method displays the result and then retains the cursor in the same line, next to the end of the result. println() displays the result and then throws the cursor to the next line.
    5. Q. What happens if String args[] is not written in main() method ?
      A.When main() method is written without String args[] as:Public static void main()-The code will compile but JVM cannot run the code because it cannot recognize the main() as the method from where it should start execution of the Java program. Remember JVM always looks for main( ) method with string type array as parameter.
    6. Q. What is the difference between float and double?
      A.Float can represent up to 7 digits accurately after decimal point, where as double can represent up to 15 digits accurately after decimal point.
    7. Q. What is a Unicode system ?
      A.Unicode system is an encoding standard that provides a unique number for every character, no matter what the platform, program, or language is. Unicode uses 2 bytes to represent a single character.
    8. Q. How are positive and negative numbers represented internally?
      A.Positive numbers are represented in binary using 1’s complement notation and negative numbers are represented by using 2’s complement notation.
    9. Q. What are control statements
      A.Control statements are the statements which alter the flow of execution and provide better control to the programmer on the flow of execution. They are useful to write better and complex programs.
    10. Q. Out of do While and while – – which loop is efficient?
      A.In a do..while loop, the statements are executed without testing the condition , the first time. From the second time only the condition is observed. This means that the programmer does not have control right from the beginning of its execution. In a while loop, the condition is tested first and then only the statements are executed. This means it provides better control right from the beginning. Hence, while loop is move efficient than do.. while loop.
    11. Q. What is a collection?
      A.A collection represents a group of elements like integer values or objectsExamples for collectionsare arrays and java.util_classes (stack, LinkedList, ;Vector, etc).
    12. Q. Why goto statements are not available in Java?
      A.Goto statements lead to confusion for a programmer. Especially in a large program, if several goto statements are used, the programmer would be perplexed while understanding the flow from where to where the control is jumping.
    13. Q. On which memory, arrays are created in Java?
      A.Arrays are created on dynamic memory by JVM. There is no question of static memory in Java; every thing( variables, array, object etc.) is created on dynamic memory only.
    14. Q. Can you call the main( ) method of a class from another class ?
      A.Yes , we can call the main( ) method of a class from another class using Classname.main() . At the time of calling the main() method, we should pass a string type array to it.
    15. Q. Is String a class or data type ?
      A.String is a class in java.lang package. But in Java, all classes are also considered as data types. So we can take String as a data type also.
    16. Q. Can we call a class as a data type ?
      A.Yes, a class is also called ‘ user-defined’ data type. This is because a use can create a class.
    17. Q. What is object reference?
      A.Object reference is a unique hexadecimal number representing the memory address of the object. It is useful to access the members of the object.
    18. Q. What is difference between == and equals( ) while comparing strings.which one is reliable ?
      A.== operator compares the references of the string objects. It does not compare the contents of the objects. equals ( ) method compares the contents. While comparing the strings, equals( ) method should be used as it yields the correct result.
    19. Q. What is a string constant pool?
      A.Sring constant pool is a separate block of memory where the string objects are held by JVM. If a string object is created directly, using assignment operator as: String s1 = “Hello”,then it is stored in string constant pool.
    20. Q. Explain the difference between the following two statements: 1. String s=”Hello” 2. String s = new String (“Hello”);
      A.In the first statement, assignment operator is used to assign the string literal to the String variable s. In this case, JVM first of all checks whether the same object is already available in the string constant pol. If it is available, then it creates another reference to it. If the same object is not available, then it creates another object with the content “Hello “and stores it into the string constant pool.In the second statement, new operator is used to create the string object; in this case, JVM always creates a new object without looking in the string constant pool.
    21. Q. What is the difference between String and StringBuffer classes?
      A.String class objects are immutable and hence their contents cannot be modified. StringBuffer class objects are mutable, so they can be modified. Moreover the methods that directly manipulate data of the object are not available in String class. Such methods are available in StringBuffer class.
    22. Q. Are there any other classes whose objects are immutalbe ?
      A.Yes, classes like Character, Byte, Integer, Float, Double, Long..called ‘wrapper classes’ are created as ‘immutable’.Classes like Class, BigInteger, Big Decimal are also immutable.
    23. Q. What is object oriented approach?
      A.Object oriented programming approach is a programming methodology to design computer programs using classes and objects.
    24. Q. What is the difference between a class and an object?
      A.A class is a model for creating objects and does not exist physically. An object is any thing that exists physically.Both the classes and objects contain variables and methods.
    25. Q. What is encapsulation?
      A.Encapsulation is a mechanism where the data(varialbes) and the code(methods) that act on the data will bind together. For ex,if we take a class, we write the variables and methods inside the class. Thus, class is binding them together. So class is an example for encapsultion.
    26. Q. What is abstraction?
      A.Hiding the unnecessary data from the user and expose only needed data is of interest to the user.
      A good example for abstraction is a car. Any car will have some parts like engine, radiator, mechanical and electrical equipment etc. The user of the car (driver) should know how to drive the car and does not require any knowledge of these parts. For example driver is never bothered about how the engine is designed and the internal parts of the engine. This is why, the car manufacturers hide these parts from the driver in a separate panel, generally at the front.
    27. Q. What is Inheritance?
      A.It creates new classes from existing classes, so that the new classes will acquire all the features of the existing classes is called inheritance. (or) Acquiring the all properties from base class to child class.
    28. Q. What is Polymorphism?
      A.The word ‘Polymorphism’ came from two Greek words ‘poly’ meaning ‘many’ and ‘morphs’ meaning ‘forms’ . Thus, polymorphism represents the ability to assume several different forms. In programming, we can use a single variable to refer to objects of different types and thus, using that variable we can call the methods of the different objects. Thus a method call can perform different tasks depending on the type of the object.
    29. Q. What is the difference between object oriented programming launguages and object based programming languages?
      A.Object oriented programming languages follow all the features of Object Oriented Programming System(OOPS). Smalltalk, Simula-67,C++, Java are examples for OOPS languages.Object based programming languages follow all the features of OOPS except Inheritance. For example, JavaScript and VBScript will come under object based programming languages.