Java interview questions - part 1
Addressing Portability: Many computers of different types with several operating
systems are connected to network / internet.............
Read
answer
The integer and floating-point types are different in terms of the consumption
of the bits which represent them. There are certain data types which are
rightly apt for speed..............
Read answer
Endianness is the process of ordering the addressable sub units such as words,
bytes or bits in a longer word that is to store in an external
memory...............
Read answer
To enable a computer system for storing text and numbers which is understandable
by humans, there should be a code that transforms characters into
numbers...................
Read answer
A loop is a set of statements that is supposed to repeat one or more times. Java
supports 3 loops................
Read answer
The key word ‘new’ is used for creation of objects. Primitive types are to use
constants but not objects.............
Read
answer
The finalize() method of java is invoked by JVM to reclaim the inaccessible
memory location, When the ‘orphan’ object (without reference) is to be
released, JVM invokes the finalize() method, when the next..................
Read answer
Go
top
The equals() method is defined in String class in order to test whether two
strings values are same sequence of characters. The method is for exclusively
testing string objects, but not any other objects..................
Read answer
A string object that is created using “String” class is immutable. The
characters of the object can not be changed / modified. There are some methods,
such as split(), substring(), beginsWith() etc...................
Read answer
Primitive types can be passed by reference. 1.By storing the primitive type
value in an array of single element and passing it.................
Read
answer
A signature in java is a combination of elements in a list such as constructor
and methods thereby distinguishing them from other constructors and
methods..................
Read answer
A static nested class can not directly access non-static methods or fields of an
instance of its enclosing class. They can be accessed by creating the object of
the nested inner class. Where as non-static nested ....................
Read
answer
An instance variable can be declared as private to promote information
hiding.............
Read
answer
Overridden methods of super class in subclass allow a class to inherit and
behave close enough. To avoid naming conflict and signature and type and number
of parameters..............
Read answer
Go
top
The java access specifier ‘protected’ is placed proceeding the member of the
class and the access control is applicable only for that particular
definition...............
Read answer
Every exception is represented by the instance of Throwable or its subclasses.
An object can carry the information for the exception raising point to the
exception handler which catches it...............
Read
answer
When an exception is to be handled which are not java class library, a user
defined exception can be thrown. An exception can be thrown explicitly, when a
condition is met. In other words, in a situation.............
Read answer
Once an application finds an exception, responds an exception by throwing
another exception. It causes another exception. Knowing an exception that
causes another exception is very useful.....................
Read answer
The term exception lets the programmer to know that there is something
exceptional has occurred in the program. Apart from Java exception class
library, a custom.................
Read
answer
Go
top
Primitive type wrapper classes or simply wrapper classes are available in
java.lang package for providing object methods for all the eight primitive
types. All the wrapper class objects are immutable.................
Read
answer
In an application, a program continues to run until all of the threads have
ended. Hence, the main thread to finish at last is not a requirement. It is a
good programming practice to make it to run last to finish................
Read answer
Java threads can be created graciously in two ways: implementing the Runnable
interface and extending Thread class.............
Read answer
In multiple processor systems, a large algorithm will split the process into
threads. So that different processors can handle different
threads...................
Read
answer
Enumeration is type safe. Where as final variables are not. Enumeration supports
to have a blend of various values............
Read
answer
Yes I is possible for a method other than paint() or update()
to output an applet’s window. It is mandatory to obtain a graphics context by
invoking getGraphics() method............
Read answer
Go
top
The compiled Java source code is known as byte code. Java
compiler generates the byte code. The byte code can run on any platform /
machine regardless of the system’s architecture..........
Read
answer
Java strictly specifies the ranges for primitive values. The selection of values
in integer or floating point types differs based on the requirement of an
application..................
Read
answer
The char data type in Java is a single 16-bit Unicode character. It represents a
character that could be any one of the world languages..................
Read answer
The prefix operator ++ adds one to its operand / variable and returns the value
before it is assigned to the variable. In other words, the increment takes
place first and the assignment next.............
Read answer
The method indexOf() returns the first occurrence (index) of a given character
or a combination as parameter in a given string.................
Read answer
The default access specifier is one which is not specified with a key word. If
no access specifier (any one of private, protected, public) is mentioned it is
known as the default access specifier.............
Read answer
Go
top
There are two ways of affecting access levels. One, when the classes in the Java
platform are used within the developer defined classes, the access levels
determine the members of those class which can be used by the developer defined
classes................
Read answer
The event model is based on the Event Source and Event Listeners. Event Listener
is an object that receives the messages / events. The Event Source is any
object which creates the message / event...................
Read answer
The programmer assumes certain code while developing when handling exceptions.
For example, a number is passed as parameter to a method..............
Read answer
Java Native methods are useful when an application can not be written completely
in Java language. For instance, when a Java application needs to modify an
existing application which was developed.................
Read answer
Using shift operators in Java we can 1. Integer division and multiplication is
done faster. Example 84547 * 4 can be done by using 84547 << 2
.............
Read answer
Wrapper classes are used to represent primitive data types as objects. Dealing
primitive types as objects is sometimes easier. Many utility methods are
available in wrapper classes......................
Read answer
Array vs ArrayList: ArrayList is much better than Array, when the size need to
be increased dynamically. Efficiency is possible with arrays. ArrayList permits
null elements...............
Read answer
The automatic conversion of primitive int type into a wrapper class object is
called autoboxing. It does not require to type cast the int
value..................
Read answer
Go
top
Java can communicate with ActiveX objects by using Bridge2Java from IBM.
Bridge2Java is a tool for allowing the java applications for communicating with
ActiveX objects.............
Read
answer
CLASSPATH is an environment variable that communicates JVM and other java
applications for finding the java language class libraries, including the
developer’s class library............
Read
answer
1. Create an object of ByteArrayOutputStream class. ByteArrayOutputStream
bStream = new ByteArrayOutputStream();.................
Read answer
1. Create a File object. File file = new File(“path and file name
here”);..............
Read
answer
Java spaces is a technology with powerful high-level tool for the development of
distributed and collaborative applications. A simple API is provided based on
the network shared space for developing................
Read answer
The system properties are accessed by the method System.getProperties(). This
method returns a Properties object. By using the list() method of Properties,
all the system properties can be viewed...............
Read
answer
The add() methods inserts an element at a given position of the
vector...............
Read
answer
Sets can have unique values. Lists can have duplicate
values...............
Read answer
Go
top
The unsynchronized collections and their modifications, iterations are termed as
‘fail-fast’ iterators. An iterator that implements Iterable
interface..............
Read answer
The object’s current state can be persisted and retrieved by
using the concept known as ‘serialization’. This is done on an object to a
stream..........
Read
answer
Xerces is a group of libraries for parsing, serializing,
validating and manipulating XML.............
Read answer
Among various types of garbage collections, the System.gc()
performs an explicit collection of garbage calls. The other garbage collection
types are:...............
Read answer
Reflection feature in java allows an executing java program
for introspecting upon itself. It also allows for manipulating internal
properties of the program..................
Read
answer
Time is measured in nanoseconds by using the method
nanoTime() method. This method returns the current value of the most precise
system timer available in nanoseconds.............
Read
answer
The method start() invokes the run() method. If the run()
method of two threads invoked separately, they will execute one after the
other.............
Read answer
Go
top
Java Isolates is an API. It provides a mechanism to manage
Java application life cycles which are isolated from each other. They can
potentially share the underlying implementation resources............
Read answer
The following are the system properties that Java applets
read by default with System.getProperty() method:..............
Read
answer
The jvmstat is a technology for adding light weight
performance, configuration instrumentation to the HotSpot JVM. The jvmstat
provides............
Read answer
A singleton implementation is done using action class in
struts framework. It performs as a front controller and every request will go
through it............
Read
answer
The ‘length’ is an instance constant which is the size of an
array. While the ‘length()’ is a method that returns the no. of the characters
in a string..................
Read answer
The >> is right shift operator. It shifts bits towards
right. For example: 5 >> 1 returns 2. It shifts one bit towards right and
one bit is lost.................
Read answer
Anonymous Inner Classes - An inner class without a name. It
allows the declaration of the class, creation of the object and execution of
the methods in it at one shot...............
Read answer
Go
top
More java interview questions with answers
How do we allocate an array dynamically in
java?
What is the purpose of the wait (),
notify (), and notifyAll() methods?
Explain with example how to initialize an
array of objects.
What is the difference between the Boolean
& operator and the && operator?
Explain CacheRowset,
JDBCRowset and WebRowset.
How and when can we cast from one class to another?
How to send to receive datagram packet?
What is the advantage of the
event-delegation model over the earlier event inheritance model?
What is the difference
between a field variable and a local variable?
When do we need to flush an output
stream?
Explain the purpose of garbage collection
that the JVM uses.
Explain how to read a line of
input at a time.
How does Java handle
integer overflows and underflows?
Explain the difference between Integer and
int in java.
What is javap?
Explain the processes performed by java virtual machine,
i.e. loading, linking, initialization.
Topic-wise Java interview questions
|