Core Java Interview Question and Answers
1) What is the most important feature of Java?
A) Java is a platform independent language.
2) What do you mean by platform independence?
A) Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform for example Linux, Sun Solaris etc.
3) What is a JVM?
A) JVM is Java Virtual Machine which is a run time environment for the compiled java class files.
4) What is the difference between a JDK and a JVM?
A) JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM.
5) What is a pointer and does Java support pointers?
A) Pointer is a reference handle to a memory location. Improper handling of pointers leads to memory leaks and reliability issues hence Java doesn’t support the usage of pointers.
6) How you can force the garbage collection?
A) Garbage collection automatic process and can’t be forced.
7) What is OOPS?
A) OOP is the common abbreviation for Object-Oriented Programming.
8) Describe the principles of OOPS?
A) There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation.
9) Explain the Inheritance principle.
A) Inheritance is the process by which one object acquires the properties of another object.
10) what is a transient variable?
A) A transient variable is a variable that may not be serialized.
11) which containers use a border Layout as their default layout?
A) The window, Frame and Dialog classes use a border layout as their default layout.
12) Can a lock be acquired on a class?
A) Yes, a lock can be acquired on a class. This lock is acquired on the class’s Class object.
13) What is the preferred size of a component?
A) The preferred size of a component is the minimum component size that will allow the component to display normally.
14) What method is used to specify a container’s layout?
A) The setLayout() method is used to specify a container’s layout.
15) What is the Vector class?
A) The Vector class provides the capability to implement a growable array of objects
16) What is an Iterator interface?
A) The Iterator interface is used to step through the elements of a Collection.
17) How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
A) Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.
18) Which java.util classes and interfaces support event handling?
A) The EventObject class and the EventListener interface support event processing.
19) What are wrapped classes?
A) Wrapped classes are classes that allow primitive types to be accessed as objects.
20) Name three Component subclasses that support painting.
A) The Canvas, Frame, Panel, and Applet classes support painting.
Tags: Core Java - Interview Questions and Answers, Core Java Interview Question and Answers, Core Java Interview Questions, Core Java Interview Questions with Answers, Core Java Interview tips, Core Java Interview tips to remember, Top 20 Core Java Interview questions