Sei sulla pagina 1di 6

JAVA VIVA QUESTIONS

1. inventor of java (james gosling)

2. Class definition(data members and methods)

3.def. of object(it is a run-time entities in an object-oriented system or collection of data members


and methods that oerates on the data members)

4. Java features(compiled and interpreted, platform-independent and portyable, object-oriented,


robust and secure, distributed, multithreaded and interactive and high performance, dynamic and
extensible)

5. What is garbage collection?(java run-time is an automatic garbage collecting system. It


automatically frees up the memory resources used by the objects.But garbage collector cannot free
resources such as file descriptors or window system fonts.Then we have to use the method explicitly
finalize() method)

6. Data encapsulation(the wrapping up of data and methods into a single unit

7 Data abstraction(representing essential features without including the background details. Classes
uses the concept of abastraction

8. Ojects are created by using the new operator

9. Final class( a class that cannot be subclassed is known as final class)

10. Abstract class(We can indicate hat a method must always be redefined in a subclass. This is
possible by using abstract keyword for the class)

1)OOP principles

Inheritance,polymorphism,data encapsulation, dynamic binding,data abstraction

2)datatypes in java

Primitive and non primitive(classes,interface,array)

Primitive data types are-numeric(int, float,double,long,short,byte) and non numeric(char,string,Boolean)

3)how to create 1D array

int a[]=new int[3];


4)how to create 2D array

int a[][]=new int[5][5];

5)define constructor and its properties

6)types of constructors

default and parameterized

7)define method overloading

It is possible to create methods that have the same name but different parameter lists and different
definitions

8)define exception

It is an error

9)how to handle exception handling mechanism

By including the try, catch and finally block(optional)

10)how to create a user exception

Class MyException extends Exception

MException(String msg)

Super(msg);

System.out.println(msg);

11)list common java exceptions

ArithmeticException,ArrayIndexOutOfBoundsException,ArrayStoreException,FileNotFoundExcpetion,

IOException,NullPointerException,NumberFormatException,OutOfMemoryException,SecurityExcpetion,

StringIndexOutOfBoundsException,StackOverFlowExcpetion

12)define multithreading principle


All threads execute simultaneously

13)life cycle of a thread

Born state,running state,runnable state,blocked state,dead state

14)how to create a thread class

Class MyThread extends Thread

public void run()

15)what are the different thread methods

start(),stop(),yield(),destroy(),wait(),sleep(),suspend(),resume(),notify(),notifyall()

16) thread priority

setPriority(int n) where n takes 1-10 numbers

17)define synchronization

At a particular instant of time access to the resource is allowed for only one client and the other clients
will be in the queue waiting for its turn to share the resource.

1)define inheritance

A subclass is created from an existing class,the existing class is called superclass and the new class
created is called the subclass

2)types of inheritance

Single inheritance,multiple inheritance, multilevel inheritance, hierarchial inheritance

3)define multiple inheritance

When a new class is created from two or more existing classes it is called multiple inheritance ,it cannot
be implemented in java directly
4)how multiple inheritance is supported in java

By using the keyword implements and using a interface

5)define interface

It resembles like that of a class and contains final variable and abstract method

6)what is final variable

A variable whose value remains constant throughout the program is called a final variable

7)what are abstract methods

The methods which are not defined are called abstract methods, they are defined in the subclass where
interfaces are included

8)use of implements keyword

It helps in including interface into the subclass

9)method overriding

When a method in the subclass contains the same return type,name and parameter list as that of the
method in the superclass then the method is executed instead of the method in superclass,this is called
methodover riding

11)what is a anonymous class

A nameless class is called anonymous class

12)define package

Set of classes or interfaces

13)types of packages

Predefined and userdefined

14)a few API packages

API-application programming interface

Predefined-io package,language,applet package,awt package,awt.event package, javax.swing package

15)how to create a package

By using the keyword package

16)how to add a package


package p;

public class A

17)how to hide a package

Remove the keyword public from the classes in it

1)definition of all collection classes

2)what is string tokenizer :[This class is used to parse the input string and finds the delimiters]

It reads the formatted input stream

5)list byte stream classes

BufferedInputStream, BufferedOutputStream, ByteArrayInputStream, ByteArrayOutputStream,


DataInputStream, DataOutputStream, FileInputStream, FileOutPutStream,
FilterInputStream,FilterOutputStream, PrintStream, PushbackInputStream

6)list character stream classes

BufferedReader, BufferedWriter, CharArrayReader, CharArrayWriter, FileReader, FileWriter,


FilterReader, FilterWriter, PrintWriter, Reader, Writer

2)AWT controls [Label, TextField,List, Choice, Button,Checkbox]

4)What are the different layout managers

FlowLayout, BorderLayout, GridLayout, CardLayout

5)list down the Source Events and their respective source listeners and abstract methods

Source event: ActionEvent, KeyEvent, ItemEvent, MouseEvent

Source Listener: ActionListener. KeyListener, ItemListener, MouseListener

6)define an applet

It is a java program that helps us to create dynamic and attractive web pages
7)What is the life cycle of an applet

Initialization, running ,idle and dead states

8)passing parameters to applets

Trasferring data from html program into applet program

9)what are the methods of an applet

Init() , start(), stop(), paint(), destroy()

Potrebbero piacerti anche