Select Category 
 

Java Interview Questions Answers

Java Interview Question - 181 : -

What is the purpose of the enableEvents() method?

Java Interview Answer - 181 : -

The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.
 

Java Interview Question - 182 : -

Which containers use a border layout as their default layout?

Java Interview Answer - 182 : -

The Window, Frame and Dialog classes use a border layout as their default layout.
 

Java Interview Question - 183 : -

How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Java Interview Answer - 183 : -

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.
 

Java Interview Question - 184 : -

How can you force garbage collection?

Java Interview Answer - 184 : -

You can't force GC, but could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately.
 

Java Interview Question - 185 : -

How to create a thread in a program?

Java Interview Answer - 185 : -

You have two ways to do so. First, making your class "extends" Thread class. Second, making your class "implements" Runnable interface. Put jobs in a run() method and call start() method to start the thread.
 

Java Interview Question - 186 : -

What is the difference between the File and RandomAccessFile classes?

Java Interview Answer - 186 : -

The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.
 

Java Interview Question - 187 : -

What is the range of the short type?

Java Interview Answer - 187 : -

The range of the short type is -(2^15) to 2^15 - 1.
 

Java Interview Question - 188 : -

What modifiers may be used with an inner class that is a member of an outer class?

Java Interview Answer - 188 : -

A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.
 

Java Interview Question - 189 : -

What is multi-threading?

Java Interview Answer - 189 : -

Multi-threading means various threads that run in a system.
 

Java Interview Question - 190 : -

What is the  Vector class?

Java Interview Answer - 190 : -

The Vector class provides the capability to implement a growable array of objects