JAVA

JAVA INTERVIEW QUESTIONS AND ANSWERS

 

1. Who has invented java?

 

Java was invented by James Gosling, Patrick Naughton, Chris Warth, Ed Frank and Mike Sheridan at Sun Microsystems in the year of 1991.

 

2. What are the features of Java?

 

1.Java is very simple programming language

 

2. Java is an object-oriented language

 

3. java is a platform independence.

 

4. Java supports multi threading

 

5. Java is designed for distributed systems

 

6. java is robustness

 

3. What is the difference between C++ and Java?

 

Java

 

1. It is a language that gets interpreted and compiled.

 

2. It is platform independent

 

3. It supports multi-threading

 

4. It does not support multiple inheritances

 

5. It is safe and more reliable

 

6. It can be compiled using a unique compiler.

 

C++

 

1. It is also n language that needs to be compiled.

 

2. It is platform dependent

 

3. It doesn’t support multi threading

 

4. It support multiple inheritances

 

5. It is simple to use and implement.

 

6. It can be compiled with a variety of compilers.

 

4. What is meant by Java Virtual Machine?

 

It is a set of software and program components.It is a virtual computer that resides on the real computer.

 

5. What are the components of JVM?

 

1. Stack

 

2. Registers

 

3. Method area

 

4. Garbage collected Heap

 

6. What is meant by Garbage collected Heap?

 

It is consists of various objects.The memory for these objects can be allocated from this heap area.When the memory of these objects gets free, it is returned to this heap area.

 

7. What is meant by Java Virtual Machine?

 

It is a set of software and program components which takes the byte code as an input and generates the output corresponding to underlying operating systems.

 

 

8. What are the two types of Programming Languages?

 

There are two types of Programming Languages

 

1. Procedural Programming Languages

 

2. Object-oriented oriented Programming Languages

 

9. What are the access specifier present in Java?

 

1.Public

 

2. Private

 

3. Default modifier

 

10. What is meant by Protected in Java?

 

Protected mode is another access specifier which is used in Inheritance.It allows accessing the members to tell all the classes and sub classes in the same package as well as to the subclass of other packages.

 

11. What is meant by Static Members in Java?

 

The static members can be static data member or static method. The static members are those members which can be accessed without using an object.

 

12. What is the purpose of Finalization?

 

It is the purpose of finalization is to clean up the negative resources used earlier.The finalize() method must be run before invoking garbage collector.

 

13. what is meant by the Private access specifier?

 

It allows classes, methods and data fields accessible only from within the own class.The function outside the class cannot access the data members or the member function.

 

 

14. What is meant by Constructor in Java?

 

The constructor is a specialized method used for initializing the objects.The name of this method and the name of the class must be same.

 

15. What is the characteristic of objects in Java?

 

1. It is an instance of class

 

2. It is runtime entities.

 

16. What is meant by AWT?

 

The AWT stands for Abstract Windows Toolkit.It is a class library that contains various classes and interfaces that are required for graphical programming.

 

It supports for drawing graphical shapes, windows, buttons, text boxes, menus.

 

17. What is meant by Frames in Java?

 

In Java, Frame is a stand graphical window. The frame can be displayed using frame class.The frame drawn by using this class has standard minimize, maximize, and close buttons.

 

18. What are the types of Components in Java?

 

1. Buttons

 

2. Canvas

 

3. Checkbox

 

4. Choice

 

5. Container

 

6. Label

 

18. What is meant by Buttons Java?

 

Buttons are sometimes called as push Buttons. This component contains a label and when it is pressed it generates the new event.

 

19. What is meant by Canvas in Java?

 

Canvas is a special area created on the frame.The canvas is specially used for drawing the graphical components such as oval, rectangle, line.

20.What is meant by Scrollbars in Java?

 

Scrollbars can be represented by the slider widgets.There are two styles of Scrollbars

 

1. Horizontal Scrollbars

 

2. Vertical Scrollbars

 

21. What is meant by Checkbox in Java?

 

The checkbox is a basically small box which can be ticked or not ticked.In Java, we can select the particular item using checkbox control.The control appears as small box along with the label.

 

22. What is meant by Choice in Java?

 

It is a control which allows the popup list for selection.

Choice obj=new Choice();

 

23. What is meant by List in Java?

 

It is a collection of many items.It can be selected by double-clicking it.

 

24. what is the syntax for the line in Java?

 

void drawing(int X1, int Y1,int X2,int Y2);

25. What is meant by Applet in Java?

 

Applets are the small java programs that can be used in the internetworking environment.

 

26. What are the advantages of Java Applets?

 

1. It is simple programs that provide a good user interface.

 

2. It can run many platforms such as Windows, Linux, Mac.

 

3. It is supported by most of the web browsers like IE, Netscape Navigator, Mozilla Browser.

4. It is support for Real-time Applications

 

5. It is also support for Client-server communication.

 

27. What are the Disadvantages of Applets?

 

1.It is very slow in executing time

 

2. It requires Java Plugins.

 

3. It,s GUI based programming is Complex.

 

28. What are the types of Life cycle model available in Applet?

 

1. Initialization

 

2. Running state

 

3. Idle state

 

4. Dead or Destroyed state.

 

29. How to run Applet?

 

There are two methods to run the Applet.

 

1. Using Web browser

 

2. Using Applet viewer

 

30. What is meant by Initialization state in Java?

 

While applets get start loaded it enters in the initialization.For this purpose only init() method is used.In this method, we can initialize the required variables.

 

31. What is meant by Event?

Event means any activity that interrupts the current ongoing activity.

 

32. What is meant by Event Source in Java?

 

Event Source is the object that generates the event. For example, if you click a button an Action Event object is generated.

 

33. What is meant by Event Classes in Java?

 

Event Classes responsible for handling events in the event handling mechanism.

 

32. What is meant by Action Event in Java?

 

The Action Eventvent object is generated when a component is activated.If a button is pressed or a menu item selected then this event occurs.

 

33. What is meant by Adjustment Event?

 

An Adjustment Event is generated when scrollbars are used.

 

34. What is meant by Event Listeners?

 

The task of handling an event is carried out by EventListener.

 

35. What are the benefits of the Inheritance in Java?

 

Not only in Java, in programming world the benefit of Java is

1. Software reusability

 

2. Code sharing

 

3. Software components

 

4. Consistency of interface

 

5. Rapids prototyping

 

36. What is meant by Inner class in Java?

 

 

An inner class is the nested classes.That means these are classes that are defined inside the other classes.

 

Access_modifier class Outerclass

{

//code

{

Access_modifier class Inner class

//code

}

}

 

 

 

37. What are the properties of Inner class?

 

1.The outer class can inherit from many numbers of inner class

 

2. The inner class objects do not get instantiated with an outer class object.

 

3. The outer class can call the private method of inner class

 

 

38. What are the types of Inner classes in Java?

 

There are four types of Inner classes in Java

 

1. Static member classes

 

2. Member classes

 

3. Local classes

 

4. Anonymous classes

 

39. What is meant by Anonymous classes?

 

1.It is a local class without an any name

 

2. It is a one-shot-class created exactly where needed.

 

3. It is created when the class has very short body

 

4. It is created when only one instance of the class is needed.

 

5. It is used immediately after doing it.

 

40. What are the types of input stream classes?

 

1. FileInputStream

 

2. PipedInputStream

 

3. FilterInputStream

 

4. ByteArrayInputStream

 

5. SequenceInputStream

 

6. StringBufferInputStream

 

41. What are the types of Output stream classes?

 

1. FileOutputStream

 

2. PipedOutputStream

 

3. FilterOutputStream

 

4. ByteArrayOutputStream

 

42. What is meant by Adapter classes in Java?

 

It is basically class in Java that implements an interface with a set of dummy methods.The famous adapter classes in Java API are

 

1. Window Adapter

 

2. Component Adapter

 

3. Container Adapter

 

4. Focus Adapter

 

5. Key Adapter

 

43. What are the keywords are used for Exception Handling?

1. Try

 

2. Catch

 

3. Throw

 

4. Throws

 

5. Finally

 

44. What is meant by Try?

 

A block of source code that is to be monitored for the exception.

 

45. What is meant by Catch?

 

It handles the specific type of exception along with the try keyword.

 

46. What is meant by Finally?

 

It specifies the code must be executed even though the exception may or may not occur.

 

47. What is meant by Throw?

 

It is used to throw the specific exception from the program code.

 

48. What are the Limitations of AWT?

 

1.It supports limited number of GUI components

 

2. The components defined by the AWT are heavy weight components

 

3. The behavior of AWT components varies when the container os changes.

 

49. What is the use of the Logging in Java?

 

Logging is used to save the error and warning messages of the application program.In Java, the API like Logger, Level handlers are used for implementing the logging feature.

 

50. What is meant by Event-driven Programming?

 

Event-driven programming is a technique in which using the graphical user interface user invokes some activity by causing some events.

 

51. List out the swing components?

 

1. AbstrractButton

 

2. Button group

 

3. JApplet

 

4. JButton

 

5. JCheckbox

 

6. JComboBox

 

7. JRadioButton

 

52. What are the features of swing in Java?

1. It is a lightweight component

 

2. It is based on Model View Controller(MVC) pattern

 

3. It occupies less memory space.

 

 

53. What is meant by Generic?

 

Generic is a mechanism for creating a general model in which generic methods and generic classes enable programmers to specify a single method for performing the desired task.

 

 

54. What is the need of the Generic?

 

1.It serves the programmers burden of creating separate methods for handling data.

 

2. It allows Code reusability.

 

3. The compact code can be created.

 

 

55. What do you mean by a thread in Java?

 

The thread is a tiny program running continuously.It is a lightweight process in Java.

 

56. What are the different stages in a thread?

 

1. New state

 

2. Runnable state

 

3. Waiting state

 

4. Time waiting state

 

5. Blocked state

 

6. Terminated state

 

57. What is meant by synchronization?

 

When two or more threads need to access shared memory, then there is some way to ensure that access to the source will be by only one thread at the time.

 

58. What is meant by Multithreading?

 

Multithreading is an environment in which multiple threads are created and they can execute simultaneously. The multiple threads can be created either by extending the thread class or by implementing the runnable interface.

 

59. What are executors?

 

Executors is a class in Java which has a large number of factory methods which are useful for constructing thread pool.

 

60. What are the two ways of creating Thread?

 

The thread can be created using

 

1. Thread class

 

2. Runnable interface

 

61. What is Thread State?

 

Thread states represent the condition in which thread occurs when it gets processed in Java program.

 

61. What is the need for Thread?

 

In Java, threads are used to handle multiple tasks together. This kind of programming is called concurrent programming.

 

62. Name any four thread constructor?

 

1. Thread()

 

2. Thread(String name)

 

3. Thread(Runnable target)

 

4. Thread(Runnable target, String name)

 

63. What is meant by Assertions?

 

Assertions are the statements used in the Java program in order to validate it. There are two types of assertions.

 

1. Precondition

 

2. Postcondition

 

Here is the List of Top 63 Java Interview questions and answers to learn and clear the java interviews.

 

Java Interview questions and answers is more useful to the students who is studying the colleges in the related department.

 

Java Interview questions and answers is also useful for the MNC ‘s people who are working in the IT(Information technology) sectors.