important viva questions in java

Upload: aamershahbaaz

Post on 14-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Important Viva Questions in Java

    1/8

    1

    IMPORTANT VIVA QUESTIONS ON OBJECT ORIENTED PROGRAMMING

    1. What is meant by object oriented programming?2. What are properties of OOPS?3. What is class?4. What is object?5. What is inheritance?6. What is super class?7. What is sub class?8. What are the types if inheritances?9. What is abstraction?10.What is encapsulation?11.What is polymorphism?12.What is dynamic binding?

    IMPORTANT VIVA QUESTIONS ON CORE JAVA

    INTRODUCTION TO JAVA

    1. Explain about the origin of java programming language2. Why the name java is given to this particular programming language?3. Why C and C++ programming languages are called as system dependent?4. In what way java can be called as system independent?5. What are the importance features of java? ( java buzzwords)6. Define byte code7. Explain about JVM8. What is the difference between JDK and JVM? ( answer: JDK is java development tool kit

    which includes execution environment. Where as JVM is java virtual machine which is

    purely a run-time environment which can run the program but cannot compile it.

    Source code that is program written by us is compiled by javac i.e., java compiler)

    9. why java doesnt support pointer concept?10.Why java dosent support multiple inheritance directly?11.Is java a purely object oriented programming language ? (answer: yes. Because in C++

    we can write program without using class and object also. Where as, in java even to

    write a simple program we need to use classes and object. Thus, C++ supports oops

    where as java a purely object oriented programming language).

    12.Explain naming conventions in java13.What are the data types available in java and give their ranges?14.Why character variable occupies 2 bytes of memory in java?

  • 7/30/2019 Important Viva Questions in Java

    2/8

    2

    15.List all the operators available in java16.What is the difference between >> and >>> operators in java?17.What are various control structures in java and their syntaxes?18.Write the general structure of a java program19.

    How main() method is written in java and explain its syntax ?

    20.If String args[] is not written inside main() what will be result?21.Why main() method in java is declared as public, static and void ?22.Can char variable be manipulated like integers?

    Answer: yes

    char ch = A;

    System.out.println(ch++);

    Output : B ( ascii values are taken)

    23.Why goto statements are nor available in java?

    ARRAYS

    1. Define array2. What is the syntax to declare an array?3. What are the types of arrays?4. Explain about arrayname.length5. Explain about arraycopy method6. Explain about command line arguments7. What is jagged array?

    Answer: jagged array is an array that contains a group of arrays with in it. These are

    also called as IRREGULAR MULTI-DIMENSIONAL ARRAYS.jagged arrays are useful

    when we are dealing with arrays of different size.

    syntax to declare is: int x[][]=new int[2][];

    in this declaration x is jagged array of size 2.

    Memory allocation is done as follows:

    X[0] = new int[2]; // memory of array-1

    X[1]=new int[2];// memory of array-2

    8. What are 3D arrays?

  • 7/30/2019 Important Viva Questions in Java

    3/8

    3

    STRING HANDLING

    1. Define string2. How to declare and initialize a string in java?3. Is string a data type or class in java?4. What are the various string handling methods?5. What is immutability of strings?6. What is the difference between string buffer class and string class?7. What is the difference between string buffer class and string builder class?8. What is the difference between == and equals() method of string class?

    Answer:

    For comparing equality of string ,We Useequals() Method. There are two ways of comparison in java. One is "==" operator and another

    "equals()" method .

    "==" compares the reference value of string object whereas , equals() method is present in the java.lang.Object class. This method

    compares content of the string object. .

    CLASSES, OBEJCTS, CONSTRUCTORS, METHODS, KEYWORDS AND

    VARIABLES IN JAVA

    1. How to declare a class and object in java?2. Difference between a class and an object3. In how many ways values can be passed to variables in java?

    Answer: using methods, using objects and using constructors

    4. Define constructor and how to declare it?5. What are the types of constructors?6. Define copy constructor7. What are the types of variables and what is the difference between

    them?

    8. What is constructor overloading?9. What is method overloading?10.What is the difference between constructors and methods in java?11.What are static methods?12.What is static block?13.Explain about this reference

  • 7/30/2019 Important Viva Questions in Java

    4/8

    4

    14.How to relate objects in java?Answer: there are 3 ways to relate objects in java:

    Using references

    Using inner class Inheritance15.What is reference variable?16.What is inner class?17.What is the use of super keyword?18.What is method overriding?19.What are the types of polymorphism?20.Explain dynamic method dispatch concept.21.What is the use of final keyword?22.Define abstract method23.Define abstract class24.Define interface25.What is the difference between class and interface26.What are the differences between abstract class and interface27.Can one interface implement other interface?28.Can one class implement another class?29.Can a class implement an interface?

    PACKAGES1. Define package2. What are the types of packages?3. What is advantage of package in java?4. List out various built-in packages in java5. Which package is imported into java program by default?6. What is the difference between #include in C and CPP and import

    statements in java

    7. How to declare a user defined package?8. What is a sub-package and how to declare it?9. What are access specifiers in java?10.What is the difference between default and other access specifiers in

    java?

    11.Explain the properties of access specifiers in packages?

  • 7/30/2019 Important Viva Questions in Java

    5/8

    5

    EXCEPTION HANDLING

    1. Define exception2. How many types of errors are there in java and what are they?3. What is the difference between error and exception?4. Cant we call a compile time error as compile time exception?5. What are the types of exceptions?6. Which package contains all exception handling related classes? (java.lang)7. Which is the base class of all exceptions? (Throwable)8. What are the various mechanisms available for handling exceptions in java?9. What is the difference between throw and throws?10.Define finally block and its use11.Explain the process of handling exceptions in java12.List out some pre-defined exception classes in java13.

    What is userdefined exception?

    14.What happens to exception after handling it ? ( exception object will be garbagecollected )

    15.Can a catch block exist without try block? ( no)16.Can try block exist without catch block? (no)17.Can a finally block exists with our try and catch blocks? ( yes )18.Single try block can have many catch blocks (true)19.One execution of try block can handle only one exception (true)20.Exceptions can be re-thrown to the calling method (true)

    MULTI-THREADING

    1. What is thread?2. What are types of multi-tasking?3. What is the difference between multi-tasking and multi-threading?4. How to create a thread in java?5. Which package contains thread related classes and interfaces?(java.lang)6. What is the use of run() method in java?7. When will run() method is invoked?8. Explain thread life cycle9. What is the default thread for a program? (main thread)10.What is the difference between wait and notify() methods in java?11.What is thread synchronization ?12.Explain producer consumer problem13.What are the various thread priorities?14.What is thread scheduler?

  • 7/30/2019 Important Viva Questions in Java

    6/8

    6

    15.Explain wait, notify() and notifyAll() methods.16.What is thread dead lock?17.What is daemon thread?18.What are the various thread class methods?19.

    What is the difference between sleep and wait methods?

    20.Define thread group.21.What are the applications of threads?22.Explain about isAlive() and join() methods.

    STREAMS AND FILES

    1. Define stream2. What are the types of streams?3. What is difference between byte and character streams?4.

    List some of the input and output streams classes in java

    5. List some reader and writer classes in java6. Explain the process of accepting values from keyboard at run time7. Define serialization8. Define de-serialization9. List out some of the file class methods

    APPLETS AND AWT

    1. Define applet2. What are types of applets?3. Where the applet code is executed?4. Explain various methods applet life cycle5. Does applet contain main() method?6. What happens when an applet is loaded?

    Answer: the following sequence happens when an applet is loaded:

    Instance (object) for the Applet sub class is created Applet initializes it self Applet starts running

    7. Can we connect applets to data base? (no)8. What is the difference between applet and normal java application?

    Answer:

    applets are executed with in web browser and java application will beout of the browser. But both require JVM.

  • 7/30/2019 Important Viva Questions in Java

    7/8

    7

    Normal java programs has main() where as applets will have,init(),start(), stop() and destroy() methods.

    9. What is the difference between CUI and GUI?10.What are the advantages of GUI over CUI?11.

    What is AWT and why we use AWT?

    12.What is a component?13.What is the difference between window and frame?14.List some of the component classes in java?15.What is event delegation model?16.Define listener interface17.List some of the listener interfaces and methods in them.18.What is the component that has to be created irrespective of creation of

    any other component? (frame)

    19.How to create and display frame?20.How to handle the event generated on the frame?21.List out various components and listeners that handle event generated

    on these components?

    22.What is layout manager?23.List various layout managers24.What is use of paint() method ?25.When the paint() method will be called while writing programs on

    components?

    26.What is the difference between paint() and repaint() methods?27.What is the difference between choice class and list class?28.What is default layout manager for frame?( border layout)29.What is default layout manager for applet?(flow layout)30.What is adapter class and list various adapter classes?31.How to create a radio button?32.How to specify the size and starting position of the components in a

    frame?

    33.How to set layout for a frame?34.How to hide the text being typed in a text field or text area by a special

    character?

    35.List some of the component class methods?36.How to add components into the frame?37.List out the methods of mouse listener and mouse motion listener

    interfaces

    38.List methods of key listener interfaces

  • 7/30/2019 Important Viva Questions in Java

    8/8

    8

    39.What is the use of drawString() method?40.List out various Graphics class methods and their use

    COLLECTIONS

    1. What is wrapper class? Why it is used? List some wrapper classes.2. What is the use of methods like intValue(), doubleValue() etc.,, ?3. List some of the methods of various wrapper classes4. What is collection frame work?5. What is the difference between normal object and a collection class

    object?

    6. Does collection object store copies of other objects? (not objects, buttheir references are stored)

    7. List out various collection interfaces and their implementationclasses

    8. What is the difference between set and list interfaces?9. What are the various ways of retrieving elements from collection

    objects, name them?

    10.Can collection primitive data type values? ( no. Only objects arestored)

    11.What is the use of Iterator interface and what methods are involves init?

    12.Explain about list iterator interface13.

    What is the difference between iterator and list iterator interfaces?

    14.Define enumeration interface15.What is the difference between hash set, linked hash set and tree set

    classes?

    16.Explain map interface17.What is the difference between array list and linked list ?

    Answer: Elements can be added or removed from any location in

    linked list but it is not possible in array list.

    18.What is the difference between array list and vector classes?Answer: array list in not synchronized where as vector class is

    synchronized.

    19.What is the use of comparator interface?20.What is the use of Date class and list various methods available in it.

    21.What is the use of Calendar class and list various methods available in it