Anda di halaman 1dari 151

1.What Is DPh !

DF| stands for object/relatIonal mappIng. DF| Is the automated persIstence of objects In a Java
applIcatIon to the tables In a relatIonal database.

.What does DPh consIsts of !


n DF| solutIon consIsts of the followIng four pIeces:
! for performIng basIc CFU0 operatIons
! to express querIes referrIng to classes
FacIlItIes to specIfy metadata
DptImIzatIon facIlItIes : dIrty checkIng, lazy assocIatIons fetchIng
.What are the DPh IeveIs !
%he DF| levels are:
!ure relatIonal (stored procedure.)
LIght objects mappIng (J08C)
|edIum object mappIng
Full object |appIng (composItIon,InherItance, polymorphIsm, persIstence by reachabIlIty)
.What Is HIbernate!
Ibernate Is a pure Java objectrelatIonal mappIng (DF|) and persIstence framework that allows you to
map plaIn old Java objects to relatIonal database tables usIng (X|L) confIguratIon fIles.ts purpose Is to
relIeve the developer from a sIgnIfIcant amount of relatIonal data persIstencerelated programmIng
tasks.

.Why do you need DPh tooIs IIke hIbernate!


%he maIn advantage of DF| lIke hIbernate Is that It shIelds developers from messy SQL. part from
thIs, DF| provIdes followIng benefIts:
25roved 5roductIvIty
o Ighlevel objectorIented !
o Less Java code to wrIte
o o SQL to wrIte
25roved 5erfor2ance
o SophIstIcated cachIng
o Lazy loadIng
o ager loadIng
25roved 2aIntaInabIIIty
o lot less code to wrIte
25roved 5ortabIIIty
o DF| framework generates databasespecIfIc SQL for you
.What 0oes HIbernate SI25IIfy!
Ibernate sImplIfIes:


SavIng and retrIevIng your domaIn objects
|akIng database column and table name changes
CentralIzIng pre save and post retrIeve logIc
Complex joIns for retrIevIng related Items
Schema creatIon from object model
.What Is the need for HIbernate x2I 2a55Ing fIIe!
Ibernate mappIng fIle tells Ibernate whIch tables and columns to use to load and store objects.
%ypIcal mappIng fIle look as follows:

.What are the 2ost co22on 2ethods of HIbernate confIguratIon!


%he most common methods of Ibernate confIguratIon are:
!rogrammatIc confIguratIon
X|L confIguratIon (hibernate.cfg.xml)

.What are the I25ortant tags of hIbernate.cfg.x2I!


FollowIng are the Important tags of hIbernate.cfg.xml:

10.What are the Core Interfaces are of


HIbernate fra2ework!
%he fIve core Interfaces are used In just
about every Ibernate applIcatIon. UsIng
these Interfaces, you can store and retrIeve
persIstent objects and control transactIons.
SessIon Interface
SessIonFactory Interface
ConfIguratIon Interface
%ransactIon Interface
Query and CrIterIa Interfaces

11.What roIe does the SessIon Interface 5Iay


In HIbernate!
%he SessIon Interface Is the prImary Interface used by Ibernate applIcatIons. t Is a sInglethreaded,
shortlIved object representIng a conversatIon between the applIcatIon and the persIstent store. t
allows you to create query objects to retrIeve persIstent objects.

Session session = sessionFactory.openSession();
SessIon Interface roIe:
raps a J08C connectIon
Factory for %ransactIon
People who read this, also read:-
ntervIew uestIons
SF Standard Co25onents
SC! .0 CertIfIcatIon
SF ntegratIon wIth S5rIng Fra2ework
0C ntervIew uestIons

olds a mandatory (fIrstlevel) cache of persIstent objects, used when navIgatIng the object
graph or lookIng up objects by IdentIfIer

1.What roIe does the SessIonFactory Interface 5Iay In HIbernate!


%he applIcatIon obtaIns SessIon Instances from a SessIonFactory. %here Is typIcally a sIngle
SessIonFactory for the whole applIcatIonreated durIng applIcatIon InItIalIzatIon. %he SessIonFactory
caches generate SQL statements and other mappIng metadata that Ibernate uses at runtIme. t also
holds cached data that has been read In one unIt of work and may be reused In a future unIt of work

SessionFactory sessionFactory = configuration.buildSessionFactory();

1.What Is the generaI fIow of HIbernate co22unIcatIon wIth P0hS!


%he general flow of Ibernate communIcatIon wIth F08|S Is :
Load the Ibernate confIguratIon fIle and create confIguratIon object. t wIll automatIcally
load all hbm mappIng fIles
Create sessIon factory from confIguratIon object
Cet one sessIon from thIs sessIon factory
Create QL Query
xecute query to get lIst contaInIng Java objects

1.What Is HIbernate uery Language (HL)!


Ibernate offers a query language that embodIes a very powerful and flexIble mechanIsm to query,
store, update, and retrIeve objects from a database. %hIs language, the Ibernate query Language
(QL), Is an objectorIented extensIon to SQL.

1.How do you 2a5 ava Dbjects wIth 0atabase tabIes!


FIrst we need to wrIte Java domaIn objects (beans wIth setter and getter).
rIte hbm.xml, where we map java class to table and database columns to Java class
varIables.
xa25Ie :
<hibernate-mapping
<class name="com.test.User" table="user"
<property column="USER_NAME" length="255"
name="userName" not-null="true" type="java.lang.String"/
<property column="USER_PASSWJRD" length="255"
name="userPassword" not-null="true" type="java.lang.String"/
</class
</hibernate-mapping

1.What's the dIfference between Ioad() and get()!


load() vs. get() :
Ioad() get()
Dnly use the load() method If you are sure that the
object exIsts.
f you are not sure that the object exIsts,
then use one of the get() methods.
load() method wIll throw an exceptIon If the
unIque Id Is not found In the database.
get() method wIll return null If the unIque
Id Is not found In the database.
load() just returns a proxy by default and database
won't be hIt untIl the proxy Is fIrst Invoked.
get() wIll hIt the database ImmedIately.

1.What Is the dIfference between and 2erge and u5date !


Use update() If you are sure that the sessIon does not contaIn an already persIstent Instance wIth the
same IdentIfIer, and merge() If you want to merge your modIfIcatIons at any tIme wIthout
consIderatIon of the state of the sessIon.

1.How do you defIne sequence generated 5rI2ary key In hIbernate!


UsIng generator tag.
xa25Ie:
<id column="USER_ID" name="id" type="java.lang.Long"
<generator class="sequence"
<param name="table"SEQUENCE_NAME</param
<generator
</id

1.0efIne cascade and Inverse o5tIon In one-


2any 2a55Ing!
cascade enable operatIons to cascade to chIld entItIes.
cascade=allnonesaveupdatedeletealldeleteorphan

Inverse mark thIs collectIon as the Inverse end of a bIdIrectIonal assocIatIon.
Inverse=truefalse
ssentIally Inverse IndIcates whIch end of a relatIonshIp should be Ignored, so when persIstIng a
parent who has a collectIon of chIldren, should you ask the parent for Its lIst of chIldren, or ask the
chIldren who the parents are:

0.What do you 2ean by Na2ed - SL query!


amed SQL querIes are defIned In the mappIng xml document and called wherever requIred.
xa25Ie:

<sql-query name = "empdetails"
<return alias="emp" class="com.test.Employee"/
SELECT emp.EMP_ID AS ,emp.empid,,
emp.EMP_ADDRESS AS ,emp.address,,
emp.EMP_NAME AS ,emp.name,
FRJM Employee EMP WHERE emp.NAME LIKE :name
</sql-query

nvoke amed Query :


List people = session.getNamedQuery("empdetails")
.setString("TomBrady", name)
.setMaxResults(50)
.list();

1.How do you Invoke Stored !rocedures!


<sql-query name="selectAllEmployees_SP" callable="true"
<return alias="emp" class="employee"
<return-property name="empid" column="EMP_ID"/

<return-property name="name" column="EMP_NAME"/
<return-property name="address" column="EMP_ADDRESS"/
, . = call selectAllEmployees() ,
</return
</sql-query

.x5IaIn CrIterIa A!
CrIterIa Is a sImplIfIed ! for retrIevIng entItIes by composIng CrIterIon objects. %hIs Is a very
convenIent approach for functIonalIty lIke search screens where there Is a varIable number of
condItIons to be placed upon the result set.
xa25Ie :
List employees = session.createCriteria(Employee.class)
.add(Restrictions.like("name", "a%") )
.add(Restrictions.like("address", "Boston"))
.addJrder(Jrder.asc("name") )
.list();

.0efIne HIbernateTe25Iate!
org.springframework.orm.hibernate.HibernateTemplate Is a helper class whIch provIdes dIfferent
methods for queryIng/retrIevIng data from the database. t also converts checked IbernatexceptIons
Into unchecked 0ataccessxceptIons.

.What are the benefIts does HIbernateTe25Iate 5rovIde!


%he benefIts of Ibernate%emplate are :
HibernateTemplate, a SprIng %emplate class sImplIfIes InteractIons wIth Ibernate SessIon.
Common functIons are sImplIfIed to sIngle method calls.
SessIons are automatIcally closed.
xceptIons are automatIcally caught and converted to runtIme exceptIons.

.How do you swItch between reIatIonaI


databases wIthout code changes!
UsIng Ibernate SQL 0Ialects , we can swItch databases. Ibernate wIll generate approprIate hql
querIes based on the dIalect defIned.

.f you want to see the HIbernate generated SL state2ents on consoIe, what shouId we do!
n Ibernate confIguratIon fIle set as follows:
<property name="show_sql"true</property

.What are derIved 5ro5ertIes!


%he propertIes that are not mapped to a column, but calculated at runtIme by evaluatIon of an
expressIon are called derIved propertIes. %he expressIon can be defIned usIng the formula attrIbute of
the element.

.What Is co25onent 2a55Ing In


HIbernate!
component Is an object saved as a
value, not as a reference
component can be saved dIrectly
wIthout needIng to declare
Interfaces or IdentIfIer propertIes
FequIred to defIne an empty constructor

People who read this, also read:-
HIbernate ntervIew uestIons
HIbernate TutorIaI
SC! .0 CertIfIcatIon
Let S5rIng hanage SF eans
AAX ntervIew uestIons
Shared references not supported
xa25Ie:

.What Is the dIfference between sorted and ordered coIIectIon In hIbernate!


sorted coIIectIon vs. order coIIectIon :
sorted coIIectIon order coIIectIon
sorted collectIon Is sortIng a collectIon by
utIlIzIng the sortIng features provIded by the
Java collectIons framework. %he sortIng occurs
In the memory of J7| whIch runnIng Ibernate,
after the data beIng read from database usIng
java comparator.
Drder collectIon Is sortIng a collectIon by
specIfyIng the orderby clause for sortIng thIs
collectIon when retrIeval.
f your collectIon Is not large, It wIll be more
effIcIent way to sort It.
f your collectIon Is very large, It wIll be more
effIcIent way to sort It .

1.What Is the advantage of HIbernate over jdbc!


Ibernate 7s. J08C :
JDBC Hibernate
Ith J08C, developer has to wrIte code to map
an object model's data representatIon to a
relatIonal data model and Its correspondIng
database schema.
Ibernate Is flexIble and powerful DF| solutIon
to map Java classes to database tables.
Ibernate Itself takes care of thIs mappIng usIng
X|L fIles so developer does not need to wrIte
code for thIs.
Ith J08C, the automatIc mappIng of Java
objects wIth database tables and vIce versa
conversIon Is to be taken care of by the
developer manually wIth lInes of code.
Ibernate provIdes transparent persIstence and
developer does not need to wrIte code explIcItly
to map database tables tuples to applIcatIon
objects durIng InteractIon wIth F08|S.
J08C supports only natIve Structured Query
Language (SQL). 0eveloper has to fInd out the
effIcIent way to access database, I.e. to select
effectIve query from a number of querIes to
perform same task.
Ibernate provIdes a powerful query language
Ibernate Query Language (Independent from
type of database) that Is expressed In a famIlIar
SQL lIke syntax and Includes full support for
polymorphIc querIes. Ibernate also supports
natIve SQL statements. t also selects an
effectIve way to perform a database
manIpulatIon task for an applIcatIon.
pplIcatIon usIng J08C to handle persIstent data
(database tables) havIng database specIfIc code
In large amount. %he code wrItten to map table
data to applIcatIon objects and vIce versa Is
actually to map table fIelds to object
propertIes. s table changed or database
changed then It's essentIal to change object
structure as well as to change code wrItten to
map tabletoobject/objecttotable.
Ibernate provIdes thIs mappIng Itself. %he
actual mappIng between tables and applIcatIon
objects Is done In X|L fIles. f there Is change In
0atabase or In any table then the only need to
change X|L fIle propertIes.
Ith J08C, It Is developer's responsIbIlIty to
handle J08C result set and convert It to Java
objects through code to use thIs persIstent data
In applIcatIon. So wIth J08C, mappIng between
Java objects and database tables Is done
manually.
Ibernate reduces lInes of code by maIntaInIng
objecttable mappIng Itself and returns result to
applIcatIon In form of Java objects. t relIeves
programmer from manual handlIng of persIstent
data, hence reducIng the development tIme and
maIntenance cost.
Ith J08C, cachIng Is maIntaIned by hand
codIng.
Ibernate, wIth %ransparent !ersIstence, cache
Is set to applIcatIon work space. FelatIonal
tuples are moved to thIs cache as a result of
query. t Improves performance If clIent
applIcatIon reads same data many tImes for
same wrIte. utomatIc %ransparent !ersIstence
allows the developer to concentrate more on
busIness logIc rather than thIs applIcatIon code.

n J08C there Is no check that always every user
has updated data. %hIs check has to be added by
the developer.
Ibernate enables developer to defIne versIon
type fIeld to applIcatIon, due to thIs defIned
fIeld Ibernate updates versIon fIeld of database
table every tIme relatIonal tuple Is updated In
form of Java class object to that table. So If two
users retrIeve same tuple and then modIfy It and
one user save thIs modIfIed tuple to database,
versIon Is automatIcally updated for thIs tuple
by Ibernate. hen other user trIes to save
updated tuple to database then It does not allow
savIng It because thIs user does not have
updated data.

.What are the CoIIectIon ty5es In


HIbernate !
8ag
Set
LIst
rray
|ap

.What are the ways to ex5ress joIns In HL!


QL provIdes four ways of expressIng (Inner and outer) joIns:
n mplct assocIatIon joIn
n ordInary joIn In the FFD| clause
fetch joIn In the FFD| clause.
thetcstyle joIn In the F clause.

.0efIne cascade and Inverse o5tIon In one-2any 2a55Ing!


cascade enable operatIons to cascade to chIld entItIes.
cascade=allnonesaveupdatedeletealldeleteorphan

Inverse mark thIs collectIon as the Inverse end of a bIdIrectIonal assocIatIon.
Inverse=truefalse
ssentIally Inverse IndIcates whIch end of a relatIonshIp should be Ignored, so when persIstIng a
parent who has a collectIon of chIldren, should you ask the parent for Its lIst of chIldren, or ask the
chIldren who the parents are:

.What Is HIbernate 5roxy!


%he proxy attrIbute enables lazy InItIalIzatIon of persIstent Instances of the class. Ibernate wIll
InItIally return CCL8 proxIes whIch Implement the named Interface. %he actual persIstent object wIll
be loaded when a method of the proxy Is Invoked.

.How can HIbernate be confIgured to


access an Instance varIabIe dIrectIy and not
through a setter 2ethod !
8y mappIng the property wIth access=fIeld In Ibernate metadata. %hIs forces hIbernate to bypass the
setter method and access the Instance varIable dIrectly whIle InItIalIzIng a newly loaded object.

.How can a whoIe cIass be 2a55ed as I22utabIe!


|ark the class as mutable=false (0efault Is true),. %hIs specIfIes that Instances of the class are (not)
mutable. mmutable classes, may not be updated or deleted by the applIcatIon.

.What Is the use of dyna2Ic-Insert and dyna2Ic-u5date attrIbutes In a cIass 2a55Ing!


CrIterIa Is a sImplIfIed ! for retrIevIng entItIes by composIng CrIterIon objects. %hIs Is a very
convenIent approach for functIonalIty lIke search screens where there Is a varIable number of
condItIons to be placed upon the result set.
dynamic-update (defaults to false): SpecIfIes that UPDATE SQL should be generated at
runtIme and contaIn only those columns whose values have changed
dynamic-insert (defaults to false): SpecIfIes that INSERT SQL should be generated at
runtIme and contaIn only the columns whose values are not null.

.What do you 2ean by fetchIng strategy !


1etchny strcteyy Is the strategy Ibernate wIll use for retrIevIng assocIated objects If the applIcatIon
needs to navIgate the assocIatIon. Fetch strategIes may be declared In the D/F mappIng metadata, or
overrIdden by a partIcular QL or Criteria query.

0.What Is auto2atIc dIrty checkIng!


utomatIc dIrty checkIng Is a feature that saves us the effort of explIcItly askIng Ibernate to update
the database when we modIfy the state of an object InsIde a transactIon.

1.What Is transactIonaI wrIte-behInd!


Ibernate uses a sophIstIcated algorIthm to determIne an effIcIent orderIng that avoIds database
foreIgn key constraInt vIolatIons but Is stIll suffIcIently predIctable to the user. %hIs feature Is called
transactIonal wrItebehInd.

.What are CaIIback Interfaces!


Callback Interfaces allow the applIcatIon to
receIve a notIfIcatIon when somethIng
InterestIng happens to an object-for
example, when an object Is loaded, saved, or
deleted. Ibernate applIcatIons don't need to
Implement these callbacks, but they're
useful for ImplementIng certaIn kInds of
generIc functIonalIty.

.What are the ty5es of HIbernate


Instance states !
%hree types of Instance states:
%ransIent %he Instance Is not assocIated wIth any persIstence context
!ersIstent %he Instance Is assocIated wIth a persIstence context
0etached %he Instance was assocIated wIth a persIstence context whIch has been closed -
currently not assocIated

.What are the dIfferences between .0 HIbernate


Ibernate 7s J8 J.0 :
Hibernate EJB 3.0
SessIon-Cache or collectIon of loaded objects
relatIng to a sIngle unIt of work
!ersIstence ContextSet of entItIes that can be
managed by a gIven ntIty|anager Is defIned by
a persIstence unIt
X0ocIet AnnotatIons used to support ttrIbute
DrIented !rogrammIng
ava .0 AnnotatIons used to support ttrIbute
DrIented !rogrammIng
0efInes HL for expressIng querIes to the
database
0efInes L for expressIng querIes
Su55orts ntIty PeIatIonshI5s through mappIng
fIles and annotatIons In Java0oc
Su55ort ntIty PeIatIonshI5s through Java 5.0
annotatIons
!rovIdes a !ersIstence hanager A! exposed vIa
the SessIon, Query, CrIterIa, and %ransactIon !
!rovIdes and ntIty hanager nterface for
managIng CFU0 operatIons for an ntIty
!rovIdes caIIback su55ort through lIfecycle,
Interceptor, and valIdatable Interfaces
!rovIdes caIIback su55ort through ntIty
LIstener and Callback methods
People who read this, also read:-
webhethods ntervIew uestIons
webhethods uestIons
Struts TutorIaI
AAX For2 VaIIdatIon UsIng 0WP and
S5rIng
Struts ntervIew uestIons
ntIty PeIatIonshI5s are unIdIrectIonaI.
8IdIrectIonal relatIonshIps are Implemented by
two unIdIrectIonal relatIonshIps
ntIty PeIatIonshI5s are bIdIrectIonaI or
unIdIrectIonaI

.What are the ty5es of InherItance 2odeIs In HIbernate!


%here are three types of InherItance models In Ibernate:
%able per class hIerarchy
%able per subclass
%able per concrete class


Two String objects with same vaIues not to be equaI under the == operator. ExpIain How.
%he == operator compares references and not contents. t compares two objects and if they are the same object in
memory and present in the same memory location, the expression returns true else it returns false.............
Read answer
ExpIain static in java.
A static variable is attached with the class as a whole and not with specific instances of a class..............
Read answer
ExpIain Garbage coIIection mechanism in Java.
Garbage collection is also called automatic memory management as JVM automatically removes the unused
variables/objects (value is null) from the memory..............
Read answer
Can Abstract CIass have constructors?
Abstract class can have a constructor. But as we can't instantiate abstract class, we can't access it through the
object..............
Read answer......
ExpIain how Java addresses the issue of portabiIity and security.
Addressing Portability: Many computers of different types with several operating systems are connected to network /
internet.............
Read answer
Why does Java have different data types for integers and fIoating-point vaIues?
%he integer and floating-point types are different in terms of the consumption of the bits which represent them. %here
are certain data types which are rightly apt for speed..............
Read answer
eatures of Java
Java omits rarely used, poorly understood features those are available in C++. %hese features include operator
overloading, multiple inheritance, destructors, allocation and freeing of memory........
Read answer
ExpIain why Java is caIIed as PIatform independent Ianguage. ExpIain how Java executabIe executes on any
pIatform where JVM is avaiIabIe.
Java byte code can run on any OS with java installed. JVM takes care of executing of native byte code........
Read answer
ExpIain Java architecture, i.e. typicaI Java environment.
Java programming language, Java class file format , Java Application Programming nterface, Java virtual
machine......
Read answer
ExpIain the features of Java cIass. ExpIain ieIds, Methods, and Access LeveIs.
A Java class has attributes, static blocks, non-static blocks, constructors, methods and inner classes. Fields: Fields
are referred to data members whom are to be accessed by the methods, constructors of the same class and methods
of other classes........
Read answer
What is a constructor? Explain the differences between methods and constructor.
A constructor is a block of code with the same name of its defining class without return type
Ex: Employee() {.} // %he class name is Employee............
Read answer
What is instance members? Explain with an example
nstance members are the attributes and methods of a class. %hey share one copy each per object. Since an object is
an instance of a class, memory has been set aside for each object to contain its own copies of instance
members..........
Read answer
What are Java packages? ExpIain the importance of Java packages.
A package is a group of .class files.
%he .class files are organized into namespaces. %he java packages are compressed into files known as Java Archive
files........
Read answer
ExpIain Java Garbage coIIector. Why garbage coIIection? Brief expIanation of Garbage coIIection aIgorithms.
Garbage collection is the process of reclaiming heap memory space by removing orphan objects
%he objects that are no longer needed by the application are garbage collected
Garbage collection is done automatically..............
Read answer
ExpIain the importance of 'super' keyword in Java. Write code to depict the uses of 'super' keyword.
%he keyword 'super' is used for referring parent class instance
Same data members of super class hides the variables by the sub class
Ex : super.number; //number of super class is accessed.............
Read answer
Define Method overIoading. ExpIain its uses. Provide a code sampIe to expIain the uses of Method
overIoading
Java supports to define two or more methods with same names within a class.
All the methods should differ in either by the number or type of parameters.
%he method System.out.println() receives multiple parameters...............
Read answer
Describe Java string cIass. ExpIain methods of Java string cIass. ExpIain the characteristics of StringBuffer
cIass
String Class:
%he String class is immutable.
%he contents of the String object can not be changed.
String class is final class. %hat implies it can not have sub classes.
String objects can be concatenated by using + and += operators...............
Read answer
What is Java inner cIass? ExpIain the types of inner cIasses, i.e. Static member cIasses, Member cIasses,
LocaI cIasses, Anonymous cIasses
nner Class : A class defined inside another class is called an 'nner Class'.
%ypes of inner classes:..........
Read answer
ExpIain about Java refIection cIass.
Classes, interfaces, methods, instance variables can be inspected at runtime by using reflection class
%o inspect he names of the classes, methods, fields etc. need not be known
Reflection in Java is powerful and useful, when objects are needed to be mapped into tables in a database at
runtime..........
Read answer
Write some important features of Swing.
Platform independent : Swing is platform independent in both expression and implementation
Extensible : Allows plugging of custom implementations of specified framework interfaces.Users can provide custom
component implementations by overriding the default implementations..................
Read answer
ExpIain different Iayout manager in Java.
A layout manager organizes the objects in a container
Different layouts are used to organize or to arrange objects................
Read answer
What is user defined Exception? ExpIain with an exampIe.
A user defined exception is extended by Exception class.
Unconventional actions are dealt with user defined exceptions
Application demanded exceptions other than APs are defined as user defined exceptions. Ex: When the balance of
an account is below zero after withdrawl, an exception can be raised like 'NegativeBalanceException'...........
Read answer
ExpIain how to use thread cIass for MuItithreading in Java. ExpIain with an exampIe.
%hreads are used in java by
a. extending the %hread class
b. implementing the Runnable interface..............
Read answer
Difference between Stream cIasses and Reader writer cIasses
Stream Classes: %hey are byte-oriented, %hey never support Unicode characters, Supports 8-bit streams...........
Read answer
What is object SeriaIization? ExpIain the use of Persisting object.
Persisting the state of an object in a storage media is known as Object Serialization
Saving and retrieving data is one of the critical tasks for developers
By persisting objects, applications can efficiently handle them, as only one object can be used at a given point of
time.............
Read answer
ExpIain the characteristics of Java socket cIass.
%he following are certain characteristics that socket share:
1. %he socket is available as long as the network process maintains an open link to the socket
2. A socket can be named in order to communicate with other sockets in a network
3. Communication is performed by the sockets in network when the server receives the connections and requests
from them...............
Read answer
State the functionaIities of important cIasses in JDBC packages.
%he important interfaces in JDBC are:
java.sql.DriverManager: Used to manage JDBC drivers, thus establishes a connection to the database server
java.sql.Connection; Used for establishing connection to a database. All SQL statements executes within the
connection context...................
Read answer
What is endianness? Describe the ways an integer is stored in memory.
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
ExpIain why Java uses Unicode
%o 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
What are the different Ioops avaiIabIe in java? How do we choose the right Ioop for a specific job?
A loop is a set of statements that is supposed to repeat one or more times. Java supports 3 loops................
Read answer
ExpIain why we don't need to use new for variabIes of the primitive types, such as int or fIoat
%he key word 'new' is used for creation of objects. Primitive types are to use constants but not objects.............
Read answer
What is finaIize()? Is finaIize() simiIar to a destructor?
%he 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
)ava interview questions and answers - April 8,
Wbat is an abstract metbod?
An abstract method is a method which doesn't have a body, just declared with modifier abstract.
plain tbe use of tbe finally block.
Finally block is a block which always executes. %he block executes even when an exception is occurred. %he block
won't execute only when the user calls System.exit()
Wbat is tbe initial state of a tbread?
t is in a ready state.
Wbat is time slicing?
n time slicing, the task continues its execution for a predefined period of time and reenters the pool of ready tasks.
Wbat are Wrapper Classes?
Wrapper Classes allow to access primitives as objects.
Wbat is List interface?
List is an ordered collection of objects.
Can you eplain transient variables in |ava?
%hey are the variables that cannot be serialized.
Wbat is syncbronization?
Synchronization ensures only one thread to access a shared resource, thus controls the access of multiple threads to
shared resources.
Wbat is serialization?
Serialization helps to convert the state of an object into a byte stream.
Wbat is HasbMap and Map?
Map is nterface and Hashmap is class that implements that.
plain tbe usage of serialization.
Objects are serialized when need to be sent over network.
%hey are serialized when the state of an object is to be saved.
How are Ubserver and Ubservable used?
%he observable class represents an observable object.
%he object to be observed can be represented by sub-classing observable class.
When there is a change in an observable instance, an application calling the Observable's notifyObservers method
causes all of its observers to be notified of the change by a call to their update method.
ifference between Swing and Awt.
AW% are heavy-weight components. Swings are light-weight components. %hus, swing works faster than AW%.
efine inner class in )ava
Class that is nested within a class is called as inner class. %he inner class can access private members of the outer
class. t is mainly used to implement data structure and some time called as a helper class.
ifferences between constructors and metbods.
A constructor is used to create objects of a class. A method is an ordinary member in a class.
Constructor does not have a return type. A method should have a return type.
Constructor name is the name of the class. A method name should not be the name of the class
Constructor is invoked at the time of creation of the class. Method needs to be invoked in another method by using
the dot operator.
Constructor can not have 'return' statement. All methods that return non-void return type should have 'return'
statement.
efine Metbod overriding. plain its uses.
Method overriding is the process of writing functionality for methods with same signature and return type, both in
super class and subclass %he uses of method overriding:
%ime to invest method signature is reduced
Different functionality in both super class and sub class by sharing same signature
%he functionality can be enhanced
%he behavior can be replaced in the sub class
Wbat is tbe purpose of tbe File class?
%he File class provides access to the files and directories of a local file system.
Wbat is StringBuffer class?
StringBuffer class is same as String class with the exception that it is mutable. t allows change and doesn't create a
new instance on change of value.
How can you force garbage collection?
t is not possible to force GC. We can just request it by calling System.gc().
s it possible an eception to be retbrown?
es, an exception can be rethrown.
Wbat is tbe return type of a program's main{] metbod?
A program's main() method has a void return type.
Wbicb package is always imported by default?
%he java.lang package is always imported by default.
)ava interview questions and answers - April 9,
Wbat is a Class?
A class implements the behavior of member objects by describing all the attributes of objects and the methods.
Wbat is an Ub|ect?
An object is the members of a class. t is the basic unit of a system. t has attributes, behavior and identity.
plain tbe use of instanceUf keyword.
instanceOf keyword is used to check the type of object.
How do you refer to a current instance of ob|ect?
ou can refer the current instance of object using this keyword.
Wbat is tbe use of )AVAP tool?
JAVAP is used to disassemble compiled Java files. %his option is useful when original source code is not available.
n wbicb package is tbe applet class located?
Applet classes are located in java.applet package.
)ava array vs. ArrayList class.
ArrayList is a dynamic array that can grow depending on demand whereas Java arrays are fixed length.
plain numeration nterface.
t defines the methods using which we can enumerate the elements in a collection of objects.
Wbat are access modifiers?
Access modifiers determine if a method or a data variable can be accessed by another method in another class.
plain tbe impact of private constructor.
Private constructor prevents a class from being explicitly instantiated by callers.
Wbat is an eception?
An exception is an abnormal condition that arises in a code sequence at run time
Wbat are ways to create tbreads?
%here are two ways to create a thread:
extend the java.lang.%hread class
implement the java.lang.Runnable interface
How can we stop a tbread programmatically?
thread.stop;
Wbat are daemon tbreads?
Daemon threads are designed to run in background. An example of such thread is garbage collector thread.
Wbat are tbe different types of locks in )BC?
%here are four types of major locks in JDBC:
Exclusive locks
Shared locks
Read locks
Update locks
Wbat are Servlets?
Servlets are program that run under web server environments.
Wbat are tbe different ways to maintain state between requests?
%here are four different ways:
URL rewriting
Cookies
Hidden fields
Sessions
Wbat are wrapper classes?
n Java we have classes for each primitive data types. %hese classes are called as wrapper class. For example,
nteger, Character, Double etc.
Wbat are cbecked eceptions?
%here are exceptions that are forced to catch by Java compiler, e.g OException. %hose exceptions are called
checked exceptions.
Wbat is tbe Locale class?
Locale class is a class that converts the program output to a particular geographic, political, or cultural region
s main a keyword in )ava?
No, main is not a keyword in Java.
Wbat is tbe most important feature of )ava?
Platform independency makes Java a premium language.
Wbat is a )VM?
JVM is Java Virtual Machine which is a run time environment for the compiled java class files.
oes )ava support multiple inberitances?
No, Java doesn't support multiple inheritances.
Wbat is tbe base class of all classes?
java.lang.Object
Can a class be declared as protected?
A class can't be declared as protected. Only methods can be declared as protected.
Can an abstract class be declared final?
No, since it is obvious that an abstract class without being inherited is of no use.
Can we declare a variable as abstract?
Variables can't be declared as abstract. Only classes and methods can be declared as abstract.
efine Marker nterface.
An nterface which doesn't have any declaration inside but still enforces a mechanism.
Wbat is an abstract metbod?
An abstract method is a method whose implementation is deferred to a subclass.
Wben can an ob|ect reference be cast to an interface reference?
An object reference is cast to an interface reference when the object implements the referenced interface.
Wbicb class is etended by all otber classes?
%he Object class is extended by all other classes.
Wbat is tbe return type of a programs main{] metbod?
void.
Wbat are tbe eigbt primitive )ava types?
%he eight primitive types are byte, char, short, int, long, float, double, and boolean.
ifference between a public and a non-public class.
A public class may be accessed outside of its package. A non-public class may not be accessed outside of its
package.
Wbicb )ava operator is rigbt associative?
%he = operator is right associative.
Wbat is a transient variable?
%ransient variable is a variable that may not be serialized.
)ava interview questions part

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
Why does String define the equaIs( ) method? Can't I just use ==?
%he equals() method is defined in String class in order to test whether two strings values are same sequence of
characters. %he method is for exclusively testing string objects, but not any other objects..................
Read answer
String objects are immutabIe in java. ExpIain how to create a string that can be changed.
A string object that is created using "String class is immutable. %he characters of the object can not be changed /
modified. %here are some methods, such as split(), substring(), beginsWith() etc...................
Read answer
Can we pass a primitive type by reference in java? How
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
What do you mean by the term signature in java?
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
Static nested cIass vs. a non-static one.
A static nested class can not directly access non-static methods or fields of an instance of its enclosing class. %hey
can be accessed by creating the object of the nested inner class. Where as non-static nested ....................
Read answer
ExpIain when we shouId make an instance variabIe private.
An instance variable can be declared as private to promote information hiding.............
Read answer
Overridden methods in Java
Overridden methods of super class in subclass allow a class to inherit and behave close enough. %o avoid naming
conflict and signature and type and number of parameters..............
Read answer
Is C++ access specifier caIIed protected is simiIar to Java's?
%he 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
Why shouId we catch super cIass exceptions?
Every exception is represented by the instance of %hrowable or its subclasses. An object can carry the information for
the exception raising point to the exception handler which catches it...............
Read answer
Why wouId we manuaIIy throw an exception?
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. n other words, in a situation.............
Read answer
What is chained exceptions in java?
Once an application finds an exception, responds an exception by throwing another exception. t causes another
exception. Knowing an exception that causes another exception is very useful.....................
Read answer
When shouId we create our own custom exception cIasses?
%he 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
What are primitive type wrappers cIasses? ExpIain the purpose of primitive type wrapper cIasses.
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
Why do you recommend that the main thread be the Iast to finish?
n 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. t is a good programming practice to make it to run last to finish................
Read answer
Why does Java have two ways to create chiId threads? Which way is better?
Java threads can be created graciously in two ways: implementing the Runnable interface and extending %hread
class.............
Read answer
Tips on effectiveIy using MuItithreading to improve the efficiency of my programs.
n multiple processor systems, a large algorithm will split the process into threads. So that different processors can
handle different threads...................
Read answer
Enumerations vs finaI variabIes in java.
Enumeration is type safe. Where as final variables are not. Enumeration supports to have a blend of various
values............
Read answer
Is it possibIe for a method other than paint() or update() to output to an appIet's window? ExpIain how.
es is possible for a method other than paint() or update() to output an applet's window. t is mandatory to obtain a
graphics context by invoking getGraphics() method............
Read answer
What is byte code and why is it important to Java's use for Internet programming?
%he compiled Java source code is known as byte code. Java compiler generates the byte code. %he byte code can
run on any platform / machine regardless of the system's architecture..........
Read answer
Why does Java strictIy specify the range and behavior of its primitive types?
Java strictly specifies the ranges for primitive values. %he selection of values in integer or floating point types differs
based on the requirement of an application..................
Read answer
What is Java's character type, and how does it differ from the character type used by many other
programming Ianguages?
%he char data type in Java is a single 16-bit Unicode character. t represents a character that could be any one of the
world languages..................
Read answer
ExpIain the difference between the prefix and postfix forms of the increment operator.
%he prefix operator ++ adds one to its operand / variable and returns the value before it is assigned to the variable. n
other words, the increment takes place first and the assignment next.............
Read answer
What is the difference between the String methods indexOf( ) and IastIndexOf( )?
%he method indexOf() returns the first occurrence (index) of a given character or a combination as parameter in a
given string.................
Read answer
ExpIain the difference between protected and defauIt access.
%he default access specifier is one which is not specified with a key word. f no access specifier (any one of private,
protected, public) is mentioned it is known as the default access specifier.............
Read answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
Java interview questions - part 3

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
ExpIain the two ways that the members of a package can be used by other packages.
There are two ways of affecting access IeveIs. One, when the cIasses in the Java pIatform are used within the
deveIoper defined cIasses, the access IeveIs determine the members of those cIass which can be used by
the deveIoper defined cIasses................
Read answer
ExpIain Java's deIegation event modeI.
The event modeI 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
Describe the assert keyword.
The programmer assumes certain code whiIe deveIoping when handIing exceptions. or exampIe, a number
is passed as parameter to a method..............
Read answer
ExpIain why a native method might be usefuI to some types of programs.
Java Native methods are usefuI when an appIication can not be written compIeteIy in Java Ianguage. or
instance, when a Java appIication needs to modify an existing appIication which was deveIoped.................
Read answer
ExpIain the use of shift operator in Java. Can you give some exampIes?
Using shift operators in Java we can 1. Integer division and muItipIication is done faster. ExampIe 84547 * 4
can be done by using 84547 << 2 .............
Read answer
Why do we need wrappers Iike Integer, BooIean for int, booIean in Java?
Wrapper cIasses are used to represent primitive data types as objects. DeaIing primitive types as objects is
sometimes easier. Many utiIity methods are avaiIabIe in wrapper cIasses......................
Read answer
Array vs ArrayList vs LinkedList vs Vector in java
Array vs ArrayList: ArrayList is much better than Array, when the size need to be increased dynamicaIIy.
Efficiency is possibIe with arrays. ArrayList permits nuII eIements...............
Read answer
Define Autoboxing with an exampIe.
The automatic conversion of primitive int type into a wrapper cIass object is caIIed autoboxing. It does not
require to type cast the int vaIue..................
Read answer
Can Java communicate with ActiveX objects? ExpIain how.
Java can communicate with ActiveX objects by using Bridge2Java from IBM. Bridge2Java is a tooI for
aIIowing the java appIications for communicating with ActiveX objects.............
Read answer
What is CLASSPATH variabIe? What is defauIt cIasspath?
CLASSPATH is an environment variabIe that communicates JVM and other java appIications for finding the
java Ianguage cIass Iibraries, incIuding the deveIoper's cIass Iibrary............
Read answer
ExpIain how to convert any Java Object into byte array.
1. Create an object of ByteArrayOutputStream cIass. ByteArrayOutputStream bStream = new
ByteArrayOutputStream();.................
Read answer
ExpIain how to convert bytes[] into iIe object.
1. Create a iIe object. iIe fiIe = new iIe("path and fiIe name here");..............
Read answer
JavaSpaces technoIogy vs. database
Java spaces is a technoIogy with powerfuI high-IeveI tooI for the deveIopment of distributed and
coIIaborative appIications. A simpIe API is provided based on the network shared space for
deveIoping................
Read answer
ExpIain the methods for accessing system properties about the Java virtuaI machine.
The system properties are accessed by the method System.getProperties(). This method returns a Properties
object. By using the Iist() method of Properties, aII the system properties can be viewed...............
Read answer
What is difference between add() and addEIement() in Vector?
The add() methods inserts an eIement at a given position of the vector...............
Read answer
What is difference between sets and Iists?
Sets can have unique vaIues. Lists can have dupIicate vaIues...............
Read answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
Java interview questions - part 4

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
What is faiI-fast iterator in Java? What is it used for?
The unsynchronized coIIections and their modifications, iterations are termed as 'faiI-fast' iterators. An
iterator that impIements IterabIe interface..............
Read answer
ExpIain how to store and retrieve seriaIized objects to and from a fiIe in Java.
The object's current state can be persisted and retrieved by using the concept known as 'seriaIization'. This
is done on an object to a stream..........
Read answer
What is reIation between JAXP and Xerces?
Xerces is a group of Iibraries for parsing, seriaIizing, vaIidating and manipuIating XML.............
Read answer
What type of garbage coIIection does a System.gc() do?
Among various types of garbage coIIections, the System.gc() performs an expIicit coIIection of garbage caIIs.
The other garbage coIIection types are:...............
Read answer
When do I need to use refIection feature in Java?
RefIection feature in java aIIows an executing java program for introspecting upon itseIf. It aIso aIIows for
manipuIating internaI properties of the program..................
Read answer
ExpIain how to measure time in nanoseconds.
Time is measured in nanoseconds by using the method nanoTime() method. This method returns the current
vaIue of the most precise system timer avaiIabIe in nanoseconds.............
Read answer
Java Thread: run() vs start() method
The method start() invokes the run() method. If the run() method of two threads invoked separateIy, they wiII
execute one after the other.............
Read answer
What is Java IsoIates and why do we need it?
Java IsoIates is an API. It provides a mechanism to manage Java appIication Iife cycIes which are isoIated
from each other. They can potentiaIIy share the underIying impIementation resources............
Read answer
What are the system properties that appIets are aIIowed to read by defauIt?
The foIIowing are the system properties that Java appIets read by defauIt with System.getProperty()
method:..............
Read answer
What is jvmstat?
The jvmstat is a technoIogy for adding Iight weight performance, configuration instrumentation to the
HotSpot JVM. The jvmstat provides............
Read answer
Describe how to impIement singIeton design pattern in struts.
A singIeton impIementation is done using action cIass in struts framework. It performs as a front controIIer
and every request wiII go through it............
Read answer
Difference between Iength and Iength()? ExpIain with an exampIe for each.
The 'Iength' is an instance constant which is the size of an array. WhiIe the 'Iength()' is a method that returns
the no. of the characters in a string..................
Read answer
Difference between >> and >>>? ExpIain with an exampIe for each.
The >> is right shift operator. It shifts bits towards right. or exampIe: 5 >> 1 returns 2. It shifts one bit
towards right and one bit is Iost.................
Read answer
What is an Anonynous inner cIass? ExpIain with an exampIe
Anonymous Inner CIasses - An inner cIass without a name. It aIIows the decIaration of the cIass, creation of
the object and execution of the methods in it at one shot...............
Read answer.
What is object deep copy and shaIIow copy? ExpIain their purposes
In deep copy the copy operations wouId respect the semantics of the object. or exampIe, copying an object
aIong with the objects to which it refers to...................
Read answer
What is dynamic variabIe in java and where do we use them?
dynamic variabIe in java..................
Read answer
ExpIain the advantages of JTA over JTS.
Java Transaction API is simpIe and more fIexibIe to use. There are two IeveIs in JTA API..................
Read answer
What is a resource Ieak?
UsuaIIy aII operating systems have Iimitations for using the number of fiIe handIes, sockets etc., which can
be open............
Read answer
What is Bootstrap Ioader program? ExpIain its purpose
Bootstrapping is a technique which activates more compIex / compIicated system of programs...............
Read answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
)ava interview questions - part

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
Can you run the java program without main method? ExpIain with an exampIe
A java applet application, a web application can run without main method. A Java program can run without using '
public static void main(String args[]) ' method by using a static block............
Read answer
Can you expIain why servIets extend HttpServIet.
Most of the web applications uses H%%Protocol. %he user requests need to be received and processed through the
H%%Protocol..............
Read answer
What is ServIet iIter and how does it work?
Filters are powerful tools in servlet environment. Filters add certain functionality to the servlets apart from processing
request and response paradigm of servlet processing.............
Read answer
ExpIain the use of <Iogic:iterate>tag in struts appIication
%he tag is utilized for repeating the nested body content over a collection. Every element / object in a specified
collection.................
Read answer
Difference between DataInputStream and BufferedReader
%he differences are: %he DatanputStream works with the binary data, while the BufferedReader work with character
data...................
Read answer
Difference between throw and throws
%he throw key word is used to explicitly throw an exception, while throws is utilized to handle checked exceptions for
re-intimating the compiler that exceptions are being handled...............
Read answer
ExpIain the ways to seriaIize the java object
Object serialization could be used in different ways: - Simple persistence of the object..............
Read answer
What are the simiIarities between an array and an ArrayList?
%he following are the similarities between an array and an ArrayList: - Both array and ArrayList can have duplicate
elements in them.................
Read answer
Can we decide a session bean as stateIess or statefuI without seeing jar fiIe? ExpIain how
A bean can be determined whether is a stateless or stateful by analyzing the deployment descriptor ejb-
jar.xml.................
Read answer
What is non static bIock in java?
%he non-static block code is executed when a new class is instantiated. t executes before the constructor's
execution...................
Read answer
ExpIain how to sort the eIements in HashMap.
%he elements of HashMap can be sorted by using the static method Collections.sort()...............
Read answer
Difference between Checked and Unchecked exception? Give some exampIes
A checked exception throws a block of code and represented by the throws keyword......................
Read answer
ExpIain why RunnabIe interface is preferabIe than extending the Thread cIass.
Runnable interface is always preferred because, the class implementing it can implement as many interfaces as a
developer can, and also extend another class...............
Read answer
Difference between a java object reference and c++ pointer.
%he prime difference is that pointers are to locate the address of the primitive variables only..............
Read answer
What is JasperReports?
Jasper Report is a very popular open source reporting tool written in Java. %he reports can be seen on the screen, on
a printer................
Read answer
Spring framework vs. Struts framework
Struts: Struts is a MVC pattern framework, Generating integration logic is done dynamically using Struts................
Read answer
ExpIain how to convert java fiIe to jar fiIes.
%he following is the process: - %ype jar cvf <jarfilename.jar> <.java file(s)>...................
Read answer
Describe how to use crystaI reports in java. Give exampIe
Create an object of CrystalReport class. - nvoke aboutBox() method for confirmation whether it is loaded properly -
Establish the connection by using setConnect() method...............
Read answer
ExpIain why java doesn't support muItipIe inheritance.
Java does not support multiple inheritances. %o avoid ambiguity problem Diamonds of Death and complexity of
multiple inheritance.....................
Read answer
What is the use of private constructor in Java? Provide an exampIe for a private constructor
A private constructor is used when there is no requirement of another class to invoke that. t is used mostly in
implementing singletons................
Read answer
ExpIain how to make a cIass immutabIe? Why do we make a cIass immutabIe
n order to make a class immutable, the changing state of the class object must be restricted. %his means restricting
an assignment to a variable...................
Read answer.
Java methods are virtuaI by defauIt. Comment.
Latest answer: Java methods are virtual by default. %he virtual methods are the methods of subclasses. %hey are
invoked by a reference of their super class...................
Read answer
ExpIain with an exampIe how a cIass impIements an interface.
Latest answer: When a class implements an interface, it has to implement the methods defined inside that interface.
%his is enforced at build time by the compiler..........................
Read answer
Concrete cIass vs. Abstract cIass vs. Interface.
Latest answer: A concrete class has concrete methods, i.e., with code and other functionality. %his class a may
extend an abstract class or implements an interface....................
Read answer
How do I design a cIass so that it supports cIoning?
Latest answer: %he Cloneable should be implemented.
clone( ) should be overridden in which super.clone( ) is called...................
Read answer
ExpIain the compIete syntax for using the AppIet tag.
Latest answer: %he <Applet> tag has the following attributes:
Code: %o specify the .class
Width: %o indicate the width of the applet window at first time loading.
Height: %o indicate the height of the applet window at first time loading..................
Read answer
Where shouId we put appIet cIass fiIes, and how to indicate their Iocation using the AppIet tag?
Latest answer: An applet class file may present in any of the folder. %he .class file name along with its current path(
in which this .html file is placed) is to be specified in the code attribute of <Applet> tag.................
Read answer
Go top
ExpIain the methods that controI a AppIet's on-screen appearance, update and paint.
Latest answer: %o refresh a page in an applet window without flashing, the update() method is to be overridden. t
clears the background of the component, before invoking paint()..................
Read answer
ExpIain how Java interacts with database. Give an exampIe to expIain it.
Latest answer: Java interacts with database using an AP called Java Database Connectivity. JDBC is used to
connect to the database, regardless the name of the database management software. Hence , we can say the JDBC
is a cross-platform AP..................
Read answer
How can we handIe SQL exception in Java?
Latest answer: SQL Exception is associated with a failure of a SQL statement. %his exception can be handled like
an ordinary exception in a catch block..................
Read answer
What is DatabaseMetaData?
Latest answer: DatabaseMetaData provides comprehensive information about the database. %his interface is
implemented by the driver vendors to allow the user to obtain information about the tables of a relational database as
a part of JDBC application...................
Read answer
What is ResuItSetMetaData?
Latest answer: ResultSetMetaData is a class which provides information about a result set that is returned by an
executeQuery() method..................
Read answer
ExpIain CacheRowset, JDBCRowset and WebRowset.
Latest answer: A CacheRowSet object is a container for rows, that 'caches' the rows in the memory..................
Read answer
What are the different types of Iocks in JDBC? ExpIain them
Latest answer: A lock is a preventive software mechanism that other users can not use the data resource..................
Read answer
How are Observer and ObservabIe used?
Latest answer: All the objects which are the instances of the sub class Observable, maintains a list of
observers..................
Read answer
What is synchronization and why is it important? Describe synchronization in respect to muItithreading.
Latest answer: Synchronization is the process of allowing threads to execute one after another..................
Read answer
What is the difference between preemptive scheduIing and time sIicing?
Latest answer: Preemptive scheduling enables the highest priority task execution until waiting or dead states
entered. t also executes, until a higher priority task enters..................
Read answer
What is a task's priority and how is it used in scheduIing?
Latest answer: A task's priority is an integer value. %his value is used to identify the relative order of execution with
respect to other tasks..................
Read answer
What is the difference between the BooIean & operator and the && operator?
Latest answer: A single ampersand is used to perform 'bit-wise AND' operation on integer arguments..................
Read answer
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Latest answer: Event-delegation model has two advantages over event-inheritance model..................
Read answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
)ava interview questions - part

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
What is the purpose of the wait (), notify (), and notifyAII() methods?
Latest answer: %he wait() method makes the thread to halt, thus allowing other thread to perform..................
Read answer
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
Latest answer: An event-listener interface allows describing the methods which must be implemented by one of the
event handler for a specific event..................
Read answer
What is the purpose of the enabIeEvents() method?
Latest answer: An event-listener interface allows describing the methods which must be implemented by one of the
event handler for a specific event..................
Read answer
What is the difference between the iIe and RandomAccessiIe cIasses?
Latest answer: %he OS based file system services such as creating folders, files, verifying the permissions,
changing file names etc., are provided by the java.io.File class..................
Read answer
What are synchronized methods and synchronized statements?
Latest answer: Synchronized methods are utilized to control the access to an object especially in multi threaded
programming..................
Read answer
ExpIain Java cIass Ioaders? ExpIain dynamic cIass Ioading?
Latest answer: %he classes are available to the JVM and are referenced by the name. After JVM starts, it introduces
the classes into it..................
Read answer
Difference between an abstract cIass and an interface and when shouId you use them
Latest answer: An abstract has one or more abstract methods apart from concrete methods. All the abstract
methods must be overridden by its subclasses..................
Read answer
What is the main difference between an ArrayList and a Vector? What is the main difference between
Hashmap and HashtabIe?
Latest answer: Differences between ArrayList and Vector:.................
Read answer
ExpIain the Java CoIIection framework? What are the benefits of the Java coIIection framework?
Latest answer: A collection is a set of heterogeneous objects. A framework makes the applications efficient, less
hard coded, similar implementation for various.................
Read answer
What is the main difference between shaIIow cIoning and deep cIoning of objects?
Latest answer: Shallow cloning just allows cloning the object but not their internal parts..................
Read answer
What is the difference between finaI, finaIIy and finaIize() in Java?
Latest answer: final a key word / access modifier to define constants..................
Read answer
What is type casting? ExpIain up casting vs down casting? When do you get CIassCastException?
Latest answer: %he conversion of a given expression from one type to another type is referred as 'type
casting'..................
Read answer
What are different types of inner cIasses?
Latest answer: %here are 4 types of inner classes - Member inner class, Local inner class, Static inner class and
Anonymous inner class.................
Read answer
What are packages in Java?
Latest answer: As the size of a project grows larger, the manageability of the files in it becomes tedious.
Read answer ..............
What are Native methods in Java?
Latest answer: Java applications can call code written in C, C++, or assembler. %his is sometimes done.................
Read answer
What is RefIection API in Java?
Latest answer: %he Reflection AP allows Java code to examine classes and objects at run time...........
Read answer
ExpIain ShaIIow and deep cIoning.
Latest answer: Cloning of objects can be very useful if you use the prototype pattern or if you want to store an
internal copy...............
Read answer
ExpIain the impact of private constructor.
Latest answer: Private Constructors can't be access from any derived classes neither from another class...............
Read answer
What are static InitiaIizers?
Latest answer: A static initializer block resembles a method with no name, no arguments, and no return
type..............
Read answer
What is the purpose of the wait (), notify (), and notifyAII() methods?
Latest answer: notify(): Wakes up a single thread that is waiting on this object's monitor................
Read answer
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Latest answer: Event-delegation model allows a separation between a component's design and its use as it enables
event handling to be handled by objects other than the ones that generate the events.......................
Read answer
What is the difference between the BooIean & operator and the && operator?
Latest answer: A & B
n this, both the operands A as well as B are evaluated and then '&' is applied to them..................
Read answer
What is a task's priority and how is it used in scheduIing?
Latest answer: A priority is an integer value...............
Read answer
What is the difference between preemptive scheduIing and time sIicing?
Latest answer: f a certain task is running and the scheduling method used is preemptive, and then if there is
another task that has a higher priority than the executing task..................
Read answer
What is synchronization and why is it important? Describe synchronization in respect to muItithreading.
Latest answer: %hreads communicate by sharing access to fields and the objects................
Read answer
How are Observer and ObservabIe used?
Latest answer: %he observable class represents an observable object.
%he object to be observed can be represented by sub-classing observable class.................
Read answer
What is ResuItSetMetaData?
Latest answer: ResultSetMetaData is an object that gets information about the types and properties of the columns
in a ResultSet object...............
Read answer
ExpIain CacheRowset, JDBCRowset and WebRowset.
Latest answer: JdbcRowSet is a connected type of rowset as it maintains a connection to the data source using a
JDBC driver.................
Read answer.
ExpIain the difference between static and non-static member of a cIass.
Latest answer: A static field belongs to a class. %he objects of the class can not have the copy of these fields. %hese
fields are referred by the class name. Ex: Employee. company. Without creating an instance of a class, these fields
can be accessed...................
Read Answer
Describe the use of "instanceof" keyword.
Latest answer: "instanceof keyword is used to check what is the type of object.................
Read Answer
What is the disadvantage of garbage coIIector?
Latest answer: Although garbage collector runs in its own thread, still it has impact on performance. t adds
overheads since JVM has to keep constant track of the object................
Read Answer
What is an AppIet?
Latest answer: An applet is a small server side application that can be loaded and controlled on the browser by the
client application...............
Read Answer
ExpIain the Iife cycIe of an appIet.
Latest answer: Below are sequences of methods that describes the life cycle of an applet............
Read Answer
What is the purpose of finaIization?
Latest answer: Finalization is the facility to invoke finalized() method. %he purpose of finalization is to perform some
action before the objects get cleaned up..............
Read Answer
What is the difference between the iIe and RandomAccessiIe cIasses?
Latest answer: %he File class is used to perform the operations on files and directories of the file system of an
operating system. %his operating system is the platform for the java application that uses the File class
objects..............
Read Answer
Define cIass and object. ExpIain them with an exampIe using java.
Latest answer: Class: A class is a program construct which encapsulates data and operations on data. n object
oriented programming, the class can be viewed as a blue print of an object.....................
Read Answer
ExpIain cIass vs. instance with exampIe using java.
Latest answer: A class is a program construct which encapsulates data and operations on data. t is a blue print of
an object..................
Read Answer
What is a method? Provide severaI signatures of the methods.
Latest answer: A java method is a set of statements to perform a task. A method is placed in a class.Signatures of
methods: %he name of the method, return type and the number of parameters comprise the method
signature...............
Read Answer
ExpIain the difference between instance variabIe and a cIass variabIe
Latest answer: An instance variable is a variable which has one copy per object / instance. %hat means every object
will have one copy of it..............
Read Answer
ExpIain how to create instance of a cIass by giving an exampIe.
Latest answer: Java supports 3 ways of creating instances - By using new operator Ex : Product prodMouse = new
Product();..............
Read Answer
What is an abstract cIass? ExpIain its purpose.
Latest answer: A class with one of more abstract methods is called an Abstract class. An abstract method is a
method with signature with out code in it...............
Read Answer
Difference between an Abstract cIass and Interface
Latest answer: An abstract class can have both abstract and concrete methods whereas an interface can have only
method signatures..................
Read Answer
What is singIeton cIass? Where is it used?
Latest answer: A class is defined as singleton class, if and only if it can create only one object. %his class is useful
when only one object is to be used in the application............
Read Answer
Difference between a pubIic and a non-pubIic cIass.
Latest answer: A class with access specifier 'public' can be accessed across the packages. A package is like a
folder in GU based operating systems. For example, the "public class String class is a public class which can be
accessed across the packages..................
Read Answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
)ava interview questions - part

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
What is Bootstrap, Extension and System CIass Ioader in Java?
Latest answer: %he Bootstrap class loader loads key Java classes. Bootstrap class loader loads the basic classes
from Java library, like java.*, javax.*. %his is the root in the class loader hierarchy..................
Read Answer
Define JDBC.
Latest answer: %he JDBC AP defines interfaces and classes for making database connections. Using JDBC, you
can send SQL.................
Read answer
Describe JDBC Architecture in brief.
Latest answer: Java application calls the JDBC library that loads a driver which talks to the database....................
Read answer
Define ResuItSet.
Latest answer: ResultSet provides access to the rows of table. A ResultSet maintains a cursor pointing to its current
row of data..................
Read answer
What are the types of JDBC drivers?
Latest answer: JDBC-ODBC bridge plus ODBC driver, also called %ype 1, Native-AP, partly Java driver, also called
%ype 2................
Read answer
Define IsoIation.
Latest answer: solation ensures one transaction does not interfere with another. %he isolation helps when there are
concurrent transactions...............
Read answer
What are the Transaction IeveIs avaiIabIe?
Latest answer: %RANSAC%ON_NONE, %RANSAC%ON_READ_UNCOMM%ED,
%RANSAC%ON_READ_COMM%%ED..........
Read answer
What is the purpose of setAutoCommit do?
Latest answer: A connection is in auto-commit mode by default which means every SQL statement is treated as a
transaction and will be automatically committed after it is executed...................
Read answer
What is JDBC driver?
Latest answer: %he JDBC Driver provided by the JDBC AP, is a vendor-specific implementations of the abstract
classes. %he driver is used to connect to the database..............
Read answer
What are the steps required to execute a query in JDBC?
Latest answer: Load JDBC drivers, Register the driver with DriverManager class...........
Read answer
What is Connection pooIing?
Latest answer: A Connection pooling is a technique of reusing active database connections instead of creating a
new connection with every request............
Read answer
What are the common tasks of JDBC?
Latest answer: Create an instance of a JDBC driver, Register a driver, Specify a database.............
Read answer
ExpIain the concepts of Exceptions in Java.
Latest answer: Exceptions are errors that occur at runtime and disrupt the normal flow of execution of instructions in
a program...............
Read answer
What is cIass Ioader? ExpIain the purpose of Bootstrap cIass Ioader.
Latest answer: Class loader finds and loads the class at runtime. Java class loader can load classes from across
network or from other sources like H%%P, F%P etc................
Read answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
)ava interview questions - part 8

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
What is a TreeSet cIass?
Latest answer: TreeSet cIass is used to store Iarge amount of data and uses tree for storage................
Read answer
String object is immutabIe, ExpIain.
Latest answer: %his means once you have created String object and assigned a value, you can't change the value of
the object.................
Read answer
Difference between traditionaI java Array and ArrayIist cIass.
Latest answer: %raditional java array is fixed length whereas ArrayList supports dynamic arrays that can
grow.................
Read answer
Difference between pass by vaIue and pass by reference.
Latest answer: n pass by value, a copy of variable is passed to the method; the values of the variable can't be
changed in the method.................
Read answer
What are access modifiers in JAVA?
Latest answer: Public %he member with public modifier can be access by any other class.
Protected %he member with protected modifier can be accessed by the derived class only..............
Read answer
Define Savepoints in a transaction.
Latest answer: Using Savepoint, you can mark one or more places in a transaction and you can perform rollback to
one of those................
Read answer
What are fiIter cIass in java?
Latest answer: %he filter class in java can manipulate request before reaches to the web server. t can also
manipulate response before it reaches the client browser......................
Read answer
How do we consume a web service in java?
Latest answer: Client can consume web services in java in 3 ways...............
Read answer
What is RefIection API in Java?
Latest answer: Reflection AP allows examining, modifying the run time behaviour of java applications running in the
JVM...........
Read answer
Difference between static and dynamic cIass Ioading.
Latest answer: Static class loading: %he process of loading a class using new operator is called static class
loading.............
Read answer
What is LinkedList cIass?
Latest answer: LinkedList class implements the List interface. n addition to the List operations, the LinkedList class
supports the operations of inserting elements................
Read answer
What is LinkedHashSet cIass?
Latest answer: LinkedHashSet combines the operations of LinkedList and HashSet, with the order of prediction for
iteration..............
Read answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
)ava interview questions - part 9

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
What is Map and SortedMap Interface?
Latest answer: A map is an object that maps the keys to vaIues. Map provides the faciIity of storing eIements
without dupIicate keys. The Map interface does not provide the sorted order of key and vaIue pairs..............
Read answer
What is casting? What are the different types of Casting?
Latest answer: Type casting: ExpIicit conversion between incompatibIe types ( or ) changing entities from
one data type to another data type....................
Read answer
Advantages and disadvantages of interfaces.
Latest answer: Interfaces are mainIy used to provide poIymorphic behavior, Interfaces function to break up
the compIex designs and cIear the dependencies between objects.................
Read answer
What is MuItithreading? ExpIain how Java supports programming for muItitasking environment.
Latest answer: A thread is one of the processes of an appIication. In muItithreading, an OS aIIows different
threads of an appIication to run in paraIIeI................
Read answer.
Describe the types of Beans.
Latest answer: There are three types of Beans: StateIess Session Beans,StatefuII Session Beans, Entity
Beans...........
Read answer
ExpIain the Common use of EJB
Latest answer: The EJBs can be used to incorporate business Iogic in a web-centric appIication.............
Read answer
What are transaction isoIation IeveIs in EJB?
Latest answer: Transaction_read_uncommitted, Transaction_read_committed,
Transaction_repeatabIe_read.................
Read answer
What is Entity Bean?
Latest answer: The entity bean is used to represent data in the database. Entity beans provide a component
modeI that aIIows.....................
Read answer
What is preinitiaIization of a servIet?
Latest answer: %he process of loading a servlet before any request comes in is called preloading or preinitializing a
servlet..............
Read answer
What is the difference between JSP and ServIets?
Latest answer: JSP supports onIy HTTP protocoI. But a servIet can support any protocoI Iike HTTP, TP,
SMTP etc...............
Read answer
What is the difference between doGet() and doPost()?
Latest answer: GET Method: AII data we are passing to Server wiII be dispIayed in URL. Here we have size
Iimitation.............
Read answer
What's the difference between servIets and appIets?
Latest answer: ServIets executes on Servers whiIe AppIets executes on browser, UnIike appIets, servIets
have no graphicaI user interface..................
Read answer
What is JSP?
Latest answer: JSP is a technoIogy that returns dynamic content to the Web cIient using HTML, XML and
JAVA eIements...................
Read answer
What is co-variant return type in java? Provide an exampIe and its purpose
A covariant return type allows to override a super class method that returns a type that sub class type of super class
method's return type. t is to minimize up casting and down casting............
Read answer
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
)ava interview questions - part

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
Define coIIabIe coIIections in java.
A callable collection is an interface whose implementers define a single method with no arguments. %he Callable
interface resembles Runnable.............
Read answer
Purpose of making a method thread safe. How to make a method thread safe without using synchronized
keyword?
Java supports threads natively without using additional libraries. Using 'synchronized' key word makes the methods
thread safe...............
Read answer
Can you expIain why a constructor doesn't have return type?
%he primary goal of a constructor is to create an object. %hough the constructor resembles a method, its explicit
purpose is to initialize the instance variables................
Read answer
ExpIain how to add a button in appIet.
%he following are the steps to add a button in applet: 1. Declare and create the object of Button class - Button
clickMe;..............
Read answer
ExpIain the purpose of jar fiIe. Can you expIain how to create a jar fiIe in java.
A Jar file contains mostly .class files and optionally other files like sound files, image files for Java applications,
gathered into a single file in the compressed format..............
Read answer.
Difference between String s="heIIo"; and String s=new String("heIIo"); in Java
%he statement String s = "hello is initialized to s and creates a single interned object................
Read answer
Java vs. Javascript.
%he differences of Java and Java Script are: - Java can stand on its own where as Java Script mandatorily be placed
within an H%ML document.............
Read answer
ExpIain upcasting and downcasting in Java. Give an exampIe
Upcasting: Java permits an object of a sub class can be referred by its super class. t is done automatically............
Read answer
Can you expIain benefits of cIasspath?
Classpath is the path in which JVM searches for class libraries at the time of compiling the Java Application. By
setting the CLASSPA%H environment variable............
Read answer
ExpIain the reason of Out of Memory exception in Java.
%he OutOfMemoryException can occur either the JVM may have a limit of memory to access to, or the system may
have run out of physical memory...........
Read answer
What wiII happen when ResuItSet is not cIosed?
n a pooled database connection, it is returned to the pool and could close only after expiring its life time............
Read answer
ExpIain the use of CIonabIe,and seriaIizabIe interface.
%he similarity of Clonable and Serializable interfaces is that they both are marker interfaces.............
Read answer .
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
)ava interview questions - part

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
Jan 12, 2011, 11:00 am by RahuI
Explain how to force the garbage collection in Java.
Advantages and disadvantages of Java Sockets.
What do you understand by Synchronization? Why is it important?
Constructors and normal methods
What is an immutable class? How to create an immutable class?
Difference between ArrayList and vector.
plain bow to force tbe garbage collection in )ava.
O First of all Garbage collection is an automatic process and can't be forced. Although, you can request it by
calling System.gc().
O JVM does not guarantee that GC will be started immediately.
O Every class inherits finalize() method from java.lang.Object.
O %he finalize() method is called by garbage collector when it determines no more references to the object
exists.
O ou can sent request to recycle the unused objects by calling System.gc() and Runtime.gc() , but there is no
guarantee when all the objects will garbage collected.
Advantages and disadvantages of )ava Sockets.
Advantages of Java Sockets:
O Sockets are flexible and easy to implemented for general communications.
O Sockets cause low network traffic unlike H%ML forms and CG scripts that generate and transfer whole web
pages for each new request.
Disadvantages of Java Sockets:
O Socket based communications allows only to send packets of raw data between applications.
O Both the client-side and server-side have to provide mechanisms to make the data useful in any way.
Wbat do you understand by Syncbronization? wby is it important?
O Synchronization is a process of controlling the access of shared resources by the multiple threads
O t allows only one thread can access one resource at a time.
O t ensures one thread not to modify a shared object while another thread is in the process of using or
updating the object's value.
O %his often leads to significant errors. Synchronization prevents such type of data corruption.
Synchronizing a function:
public synchronized void SyncMet()
{
// Appropriate method-related code.
}
Constructors and normal metbods
O Constructors must have the same name as the class.
O Constructors can not return a value.
O
O Normal methods are only called once while regular methods can be called many times
O Normal methods can return a value or can be void.
Wbat is an immutable class? How to create an immutable class?
O mmutable class is a class which once created, it's contents can not be changed.
O mmutable objects are the objects whose state can not be changed once constructed.
O Since the state of the immutable objects can not be changed once they are created they are automatically
synchronized/thread-safe.
O mmutable objects are automatically thread-safe since the state of the immutable objects can not be
changed once they are created
O All wrapper classes in java.lang are immutable
String, nteger, Boolean, Character, Byte, Short, Long, Float, Double, BigDecimal, Bignteger
ifference between ArrayList and vector.
O ArrayList is not thread-safe whereas Vector is thread-safe.
O n Vector class each method is surrounded with a synchronized block and thus making Vector class thread-
safe.
O Both the ArrayList and Vector hold onto their contents using an Array.
O When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if
it runs out of room.
O A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
Most common )ava questions

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
What is the Java alternative for size operator in C. Explain with an example.
Which one of the following is faster in java and why?
1. for(int i = 100000; i > 0; i--) {}
2. for(int i = 1; i < 100001; i++) {}
Which one of the following is faster in java and why?
1. Math.max(a,b);
2. (a>b)?a:b
Explain which of the following is faster and why?
Array operations
Vector
Which one of these primitive types are unsigned?
int
long
char
double
float
s it true that Java supports both multi dimension and nested arrays?
s it possible a class without a method to be run by JVM if its ancestor class has main?
s GC a high priority thread?
Can an interface be final?
Can the object be garbage collected, f there is an exception in finalize method?
Can finalize method be overloaded?
Does the finalize method in subclass invoke finalize method in super class?
What are the different types of inner classes? Explain them
What will be output from the following statements:
1. System.out.println(1+2+3);
2. System.out.println ("1+2+3);
Explain the use of volatile variable.
Can an nterface be final?
Can there be an abstract class with no abstract methods in it?
Can we have static method in interface?
Dictionary is an interface or class?
Can constructor throw exception?
s it possible Local variables to be declared static or final or transient?
What is the use of transient variable? Can a transiant variable be static?
Can inner class have static members?
s there any method in a File class to read or write content in a file?
What is the rule regarding overriding methods throwing exceptions?
When do Member variables get resolved? compiletime or runtime
Can a class implement two interfaces which has got methods with same name and signatures?
Can a class implement two interfaces with same variable names?

What tags are mandatory when creating H%ML to display an applet?
Which classes and interfaces does Applet class consist?
Which Component subclass is used for drawing and painting?
What interface is extended by AW% event listeners?
Which class is the immediate superclass of the MenuComponent class?
n which package are most of the AW% events that support the event-delegation model defined?
What class is the top of the AW% event hierarchy?
What is the immediate superclass of the Dialog class?
Name three Component subclasses that support painting
What is the immediate superclass of the Applet class?
which containers use a border Layout as their default layout?
Does java support pointers?
Does java support global variables?
Can an inner class declared inside of a method access local variables of this method?
t is valid to declare an inherited method as abstract?
Which is garbage collected first: Normal variables or static variables?
Can we overload main method in java?
Does object serialization support encryption?
Can we sort an Hashtable?

What is the purpose of the System class?
What is the advantage of the event-delegation model over the earlier event-inheritance model?
What classes of exceptions may be caught by a catch clause?
Explain the difference between the Reader/Writer class hierarchy and the nputStream/OutputStream class hierarchy.
What is the purpose of finalization?
How many times may an object's finalize() method be invoked by the garbage collector?
What is the difference between the Boolean & operator and the && operator?
What must a class do to implement an interface?
What is the purpose of the finally clause of a try-catch-finally statement?
Can a lock be acquired on a class? Explain how with an example
What is synchronization and why is it important?
How are Observer and Observable used?
Why do threads block on /O?
What are wrapped classes? Provide an example
How does Java handle integer overflows and underflows?
What is the difference between preemptive scheduling and time slicing?
What is a native method? Provide an example
What is a task's priority and how is it used in scheduling?
What are the two important %CP Socket classes? Explain them
What information is needed to create a %CP Socket?
Difference between URL instance and URLConnection instance.

main() in java taking String[] as argument. Could you explain the reason
Why java is called as PLA%FORM independent?
Why all classes in Java extend Object class implicitly?
What is the difference between inheritance and aggregation? When would you use one over the other?
What is meant by Virtual function in Java? Does Java supports Virtual function?
What is the difference between break, continue and return statements?
Why Java is not complete Object Oriented Programming language?
Can main() of one java program be invoked in another java program's main()? Explain in an example
Why do we require public static void main(String args[]) method in Java programme?
Explain play audio clips without using applet class.
How do you do to display a String on the applet?
Explain the methods to retrive information about an applet.
What is AppletStub nterface? Explain its importance
Explain with an example how to determine the width and height of my application.
How do you ensure different applets on a web page to communicate with each other?
Explain the differences between Applets and Applications.

What is the sequence for calling the methods by AW% for applets?
Explain the Applet's Life Cycle methods.
What is the importance of layout managers in Java? Explain the problems faced by Java programmers who dont use
layout managers
Explain the difference between a Choice and a List
llustrate with an example how the Checkbox class can be used to create a radio button
Difference between the paint() and repaint() methods
Explain the advantage of Java's layout managers provide over traditional windowing systems
What is the relationship between an event-listener interface and an event-adapter class?
What are clipping and repainting in Java? What is the relationship between clipping and repainting?
How are the elements of a CardLayout organized?
Explain the difference between the Font and FontMetrics classes
Explain the difference between a Window and a Frame.
How are the elements of a BorderLayout organized?
Explain the relationship between the Canvas class and the Graphics class.
Explain the difference between a Menutem and a CheckboxMenutem.
What is clipping?
Which containers use a FlowLayout as their default layout? Discuss in Detail

Why variables/objects in java bean classes are declared as private?
How to increase stack size in Java?
Explain the difference between local variable and temporary variable. Can you give example.
What do you mean by Legacy class?
What is PermGen space?
We can't declare a static method in an interface. Explain
What is marker interface and What is the use of marker interface?
Explain the difference between ArrayList and LinkedList.
What is the difference between local inner class and non-local inner class?
What are dynamic class loaders?
What are the different ways in which polymorphism can be achieved in java?
Explain the differences between inheritance and composition
Can an interface have variables defined in it? How do you use them?
Explain the disadvantage of using an inner class
What are the different inner classes available in java? Explain each inner class with an example
Can an exception be re-thrown? Explain with an example
What is %ight Encapsulation? Explain its importance

Can you explain how a try statement determines which catch clause should be used to handle an exception?
Explain the difference between a queue and a stack
Explain difference between Shallow Copy and Deep Copy.
Explain how to create an ObjectnputStream from an ObjectOutputStream without a file in between.
Explain how to write objects to a random access file.
Describe why U%FDataFormatException is thrown by DataOutputStream.writeU%F() when serializing a String.
Explain how to get the serialVersionUD of a class.
Why is OutOfMemoryError thrown after writing a large number of objects into an ObjectOutputStream?
Explain the purpose of the Runtime class
What is an /O filter?
Explain the difference between the File and RandomAccessFile classes.
What is difference between jsp and Servlet?
Explain nstance Variables and Class Variables
Difference between ArrayList and Vector
Difference between Abstract classes and nterfaces
What is Singleton Class? Explain its importance
What are Checked and Un-Checked Exceptions? Explain.
Difference Between Abstraction and Encapsulation
What is user defined exception? Provide an example
Why is not recommended to have instance variables in nterface?
Difference between logical data independence and physical data independence

Explain the benefits of importing a specific class rather than an entire package.
Difference between instanceof and isnstance
Describe what happens when an object is created in Java.
What is pass by ref and pass by value?
mportance of final keyword.
mportance of abstract keyword
What is constructor chaining and how is it achieved in Java?
What are synchronized methods and synchronized statements?
What is a stateless protocol? Explain its importance
How does a try statement determine which catch clause should be used to handle an exception?
What restrictions are placed on method overriding?
What interface must an object implement before it can be written to a stream as an object?
What is the difference between the prefix and postfix forms of the ++ operator?
What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown
within the body of the try statement?
How can a dead thread be restarted?

What happens when you add a double value to a String?
Difference between the File and RandomAccessFile classes
How are this() and super() used with constructors? llustrate in an example
Can an exception be rethrown? How
What is the purpose of the File class?
Difference between a while statement and a do statement. Give example for both
What restrictions are placed on the values of each case of a switch statement?
What are the different identifier states of a %hread? Explain in brief each of them
Whats the difference between notify() and notifyAll()?
Difference between DAO (Data Access Object ) and DAC (Data Access Component).
Difference between inheritance and decorator design pattern.
What are the drawbacks of using Observer Pattern and how do you overcome them?
What are Data %ransfer Objects and where are they used?
)ava Struts interview questions
Explain the difference between Action messages and Action errors.
Explain the tokens available in Struts.
Explain how to handle multiple forms using Struts.
Explain ActionForward against JSP:forward.
What happens internally when actionMappings.findForward(target) method is called in Action class.
What is the role of ActioMapping object in Struts Action class?
What is Struts Validator Framework? Explain its importance
What is ActionServlet in Apache Struts?
How do struts handle messages required for the application?
What is Action Class? Can you explain its importance
What is ActionForm class? Can you explain its importance
What are peerless components?
What is the advantage of DispatchAction class?
Difference between paint(), repaint() and update() methods within an applet which contains images.
When should the method invokeLater()be used?
Explain how struts handles to display the validation messages?
Explain How to enable front-end validation based on the xml in validation.xml.
)ava Swing interview questions
Which Swing methods are thread-safe and why?
Difference between paint() and paintComponent()
Difference between invokeAndWait() and invokeLater()
Difference between a Scrollbar and a ScrollPane.
Explain how to detect a keypress in a JComboBox.
Explain how to create a button with rounded edges.
Why do we use SwingUtilities.invokeAndWait or SwingUtilities.invokeLater?
Why does it take so much time to access an Applet having Swing Components the first time?
Why does JComponent have add() and remove() methods but Component does not?
Why should the implementation of any Swing callback (like a listener) execute quickly?
)ava Tbreads interview questions
What is a Deadlock state of a thread?
What is a daemon thread?
What happens when you call yield() on a thread?
Difference between yielding and sleeping.
Difference between Multitasking and Multithreading.
Can you explain the difference between green threads and native threads?
What are three ways in which a thread can enter the waiting state?
What method must be implemented by all threads?
What happens when you invoke a thread's interrupt method while it is sleeping or waiting?
What are the high-level thread states? Explain them
What is the purpose of the wait(), notify(), and notifyAll() methods?
What invokes a thread's run() method? llustrate in an example
eneral )ava interview questions
What is a design pattern?
Describe the visitor design pattern
How would you guarantee sorting of objects in a class that implements Map interface?
How can u avoid the conflict between java.util.Date and java.sql.Date?
What is the difference between terator and Enumeration?
What is the ResourceBundle class?
What is the purpose of the enableEvents() method?
What is the Vector class?
What is the ResourceBundle class?
What is the Simple%imeZone class?
What is the Locale class?
What is the List interface?
What is the highest-level event class of the event-delegation model?
What is the GregorianCalendar class?
Which java.util classes and interfaces support event handling?
What is an terator interface?
What is the Set interface?
What is the Collections AP?
What is the Properties class?
What is the difference between ArrayList and Vector?
What is the default size of the vector?
What does loadFactor mean in collection framework? E.g. HashMap
When use MyClass object as a key in a Hashtable, what methods should override in MyClass and why?
What is the Collection interface?
What is the Map interface?
What is the difference between HashSet and LinkedHashSet?
How does an included file in jsp look in the compiled .java file?
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14


)ava Multi-Tbreading interview questions

<<Previous Next>>
Preemptlve xcheJullng vx. tlme xllclng.
n preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher
priority task comes into existence.

n time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks.
%he scheduler then determines which task should execute next, based on priority and other factors.
Brlefly expluln Juemon threuJ.
Daemon thread is a low priority thread which runs in the background performs garbage collection operation for the
java runtime system.
hut ure the two typex of multltuxklng?
Process-based and %hread-based
Procexx unJ 1hreuJ
A process can contain multiple threads.
A process has its own memory address space whereas a thread doesn't.
%hreads share the heap belonging to their parent process.
One process cannot corrupt another process
A thread can write the memory used by another thread.
ume the wuyx to creute the threuJ.
mplementing Runnable and Extending %hread
hut lx tlmexllclng?
%imeslicing is the method of allocating CPU time to individual threads in a priority schedule.
ume the methoJx uvulluble ln the Runnuble Interfuce.
run()
ume the methoJx uvulluble ln the 1hreuJ cluxx.
isAlive(), join(), resume(), suspend(), stop(), start(), sleep(), destroy()
rlte the xlgnuture of the conxtructor of u threuJ cluxx.
%hread(Runnable threadobject,String threadName)
ume the methoJx uxeJ for Inter 1hreuJ communlcutlon.
wait(),notify() & notifyall()
ume the mechunlxm JeflneJ by juvu for the Rexourcex to be uxeJ by only one 1hreuJ ut u tlme.
Synchronisation
utu type for the purumeter of the xleep() methoJ lx
long
ProvlJe the vuluex for mux-prlorlty, mln-prlorlty unJ normul-prlorlty level.
10,1,5
ume the methoJ for xettlng the prlorlty.
setPriority()
ume the Jefuult threuJ ut the tlme of xturtlng the progrum.
main thread
ow muny threuJx ut u tlme cun uccexx u monltor?
one
ume the four xtutex uxxocluteJ ln the threuJ.
new, runnable, blocked, dead
hut lx the prlorlty for 0urbuge collector threuJ?
low-priority

<<Previous Next >>
)ava String ob|ects

<<Previous Next>>
Java - Two String objects with same values not to be equal under the == operator. Explain How. - Jan 03,
2011 at 05:16 PM by Rahul
1wo Strlng objectx wlth xume vuluex not to be equul unJer the == operutor. Fxpluln ow.
%he == operator compares references and not contents. t compares two objects and if they are the same object in
memory and present in the same memory location, the expression returns true else it returns false. t is quite possible
that two same contents are located in different memory locations.
Following function will help to understand the concept:
public class %est
{
public static void main(String[] args)
{
String str1 = "abc;
String str2 = str1;
String str5 = "abc;
String str3 = new String(abc);
String str4 = new String(abc);
System.out.println(== comparison - + (str1 == str2));
System.out.println(equals method - + str1.equals(str2));
System.out.println(== comparison - + str3 == str4);
System.out.println(equals method - + str3.equals(str4));
System.out.println(== comparison - + (str1 == str5));
}
}
Output
== comparison - true
equals method - true
== comparison - false
equals method - true
== comparison - true
<<Previous Next>>

What is the difference between preemptive scheduIing and time sIicing?


Latest answer: Preemptive scheduling enables the highest priority task execution until waiting or dead states
entered. t also executes, until a higher priority task enters...................
ExpIain how Java interacts with database. Give an exampIe to expIain it.
Latest answer: Java interacts with database using an AP called Java Database Connectivity. JDBC is used to
connect to the database, regardless the name of the database management software. Hence , we can say the JDBC
is a cross-platform AP...................

Static in |ava

<<Previous Next>>
Java - Explain static in java. - Jan 03, 2011 at 05:16 PM by Rahul
Fxpluln xtutlc ln juvu.
O A static variable is attached with the class as a whole and not with specific instances of a class.
O Each object shares a common copy of the static variables which means there is only one copy per class, no
matter how many objects are created from it.
O Static variables are declared with the static keyword in a class.
O Static variables are always called by the class name.
O t is created when the program starts and gets destroyed when the programs stops.
O Static methods are implicitly final, because overriding is done based on the type of the object
O Static methods are attached to a class, not an object.
O A static method in a superclass can be shadowed by another static method in a subclass, as long as the
original method was not declared final.
O ou can't override a static method with a non-static method which means you can't change a static method
into an instance method in a subclass.
O Non-static variables has unique values with each object instance.
O
hen lx xtutlc vurluble louJeJ? Ix lt ut complle tlme or runtlme?
O Static variable are loaded when classloader brings the class to the JVM.
O t is not necessary that an object has to be created. Static variables will be allocated memory space when
they have been loaded.
O %he code in a static block is loaded/executed only once i.e. when the class is first initialized.
<<Previous Next>>

What is the disadvantage of garbage coIIector?


Although garbage collector runs in its own thread, still it has impact on performance. t adds overheads since JVM
has to keep constant track of the object...............
Where shouId we put appIet cIass fiIes, and how to indicate their Iocation using the AppIet tag?
Latest answer: An applet class file may present in any of the folder. %he .class file name along with its current path(
in which this .html file is placed) is to be specified in the code attribute of <Applet> tag..................

arbage collection mecbanism in )ava

<<Previous Next>>
Java - Garbage collection mechanism in Java - Jan 03, 2011 at 05:16 PM by Rahul
Fxpluln 0urbuge collectlon mechunlxm ln juvu.
O Garbage collection is also called automatic memory management as JVM automatically removes the
unused variables/objects (value is null) from the memory.
O %he purpose of garbage collection is to identify and remove objects that are no longer needed by a program.
O A Java object is subject to garbage collection when it becomes unreachable to the program in which it is
used.
O Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage
collector when it determines no more references to the object exists.
O Calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects
O No guarantee that Garbage collection will start immediately upon request of System.gc().
<<Previous Next>>

What is the use of private constructor in Java? Provide an exampIe for a private constructor
A private constructor is used when there is no requirement of another class to invoke that. t is used mostly in
implementing singletons................
ExpIain why RunnabIe interface is preferabIe than extending the Thread cIass.
Runnable interface is always preferred because, the class implementing it can implement as many interfaces as a
developer can, and also extend another class...............
.
Can Abstract Class bave constructors?

<<Previous Next>>
Java - Can Abstract Class have constructors? - Jan 03, 2011 at 05:16 PM by Rahul
un Abxtruct luxx huve conxtructorx?
Abstract class can have a constructor. But as we can't instantiate abstract class, we can't access it through the
object.
%o access the constructor create a sub class and extend the abstract class which is having the constructor.
ExampIe
public abstract class clsAbstract
{
public clsAbstract()
{
System.out.println(n clsAbstract());
}
}
public class %est extends clsAbstract
{
public static void main(String args[])
{
%est o1=new %est();
}
}
<<Previous Next>>

ExpIain how Java interacts with database. Give an exampIe to expIain it.
Latest answer: Java interacts with database using an AP called Java Database Connectivity. JDBC is used to
connect to the database, regardless the name of the database management software. Hence , we can say the JDBC
is a cross-platform AP.................
Concrete cIass vs. Abstract cIass vs. Interface.
Latest answer: A concrete class has concrete methods, i.e., with code and other functionality. %his class a may
extend an abstract class or implements an interface....................
How )ava addresses tbe issue of portability and security

<<Previous Next>>
Java - Explain how Java addresses the issue of portability and security. - March 14, 2010 at 05:16 AM by
Vidya Sagar
Fxpluln how juvu uJJrexxex the lxxue of portublllty unJ xecurlty.
Addressing PortabiIity:
Many computers of different types with several operating systems are connected to network / internet. All the
programs that are dynamically downloaded to various platforms through internet, should generate code for execution
which is portable.
%he Java specification defines clearly the way of behavior. %here is a comprehensive specification for desktop
applications, JEE applications as well for EJB applications. JEE and EJB specifications are available to run the built
applications on any compatible Java application or web server. %hese specifications may be for JSE or JEE or even
EJB applications. Once the behavior is correctly implemented by various vendors, the specified application could run
on any Java specification as a contract in between the developers and the implementers of the Java specification.
%he reference implementation of JEE provides a sample implementation to the developers which is compatible for
JEE platform. t allows the developers to test the implementation and the vendors to test and verify the
implementation. %he JEE Compatibility %est Suite (C%S) is provided by Sun Microsystems. t is a standard suite with
more than 15000 test cases for the JEE applications portability.
Addressing Security:
Certain security risks like viral infection, malicious programs detection are guarded by Java enabled web browsers
and are active when a program is downloaded. %he malicious programs / virus programs could gather sensitive
information such as passwords, bank account number, credit card numbers etc. Java addresses these issues by
executing a program known as 'firewall'. %his program resides in between the downloadable program and the system
which downloads it.
Also, as far as application data is concerned, the access specifiers 'private', 'protected' can be used cautiously to
protect the data with in the scope of the application.
<<Previous Next>>
What is the disadvantage of garbage coIIector?
Although garbage collector runs in its own thread, still it has impact on performance. t adds overheads since JVM
has to keep constant track of the object................
Define cIass and object. ExpIain them with an exampIe using java.
Class: A class is a program construct which encapsulates data and operations on data. n object oriented
programming, the class can be viewed as a blue print of an object.....................


ifferent data types for integers and floating-point values
<<Previous Next>>
Java - Why does Java have different data types for integers and floating-point values? - March 14, 2010 at
05:16 AM by Vidya Sagar
hy Joex juvu huve Jlfferent Jutu typex for lntegerx unJ floutlng-polnt vuluex?
%he integer and floating-point types are different in terms of the consumption of the bits which represent them. %here
are certain data types which are rightly apt for speed and perfect memory utilization. %his makes the java applications
to execute with efficiency. For example the number 95 is within the range of byte, short, int and long integer types.
%he data type byte will occupy 8 bits, short occupies 16 bits, and int occupies 32 bits and long 64 bits. f the variable
is restricted to hold only the values -128 to +127, then throughout the application it is wise to declare that variable as
'byte'. Similar applicability is applied for the rest of integer types and floating-point types.
<<Previous Next>>
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events.......................
What are access modifiers in JAVA?
Public %he member with public modifier can be access by any other class.
Protected %he member with protected modifier can be accessed by the derived class only..............


Wbat is endianness?
<<Previous Next>>
Java - What is endianness? Describe the ways an integer is stored in memory - March 14, 2010 at 05:16 AM
by Vidya Sagar
hut lx enJlunnexx? excrlbe the wuyx un lnteger lx xtoreJ ln memory.
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. %he typical ordering of bytes is with a 16 or 32 or 64 bits word. %he usual contract is
between most and least significant byte first, known as big-endian and little-endian.
A value in computer's memory is represented as a binary number, which is a combination of 0's and 1's (bits binary
digits). %he combination of 8 bits is called as a 'byte' (8 bits = 1 byte). Memory is measured in bytes and the data type
'byte', refers to a single byte of memory. %he data type 'short' occupies 2 bytes (16 bits). For example, the byte 24
occupies 1 byte of memory space and 'short' 24 occupies 2 bytes, the 'int' occupies 4 bytes and the 'long' occupies 8
bytes. Each data type has varied range of values to represent.
%he constant 24 of byte represents 00011000
%he constant 24 of short represents 0000000000011000
%he constant 24 of int represents 00000000000000000000000000011000
%he constant 24 of long represents
0000000000000000000000000000000000000000000000000000000000011000.
<<Previous Next>>
ExpIain how Java interacts with database. Give an exampIe to expIain it.
Java interacts with database using an AP called Java Database Connectivity. JDBC is used to connect to the
database, regardless the name of the database management software. Hence , we can say the JDBC is a cross-
platform AP..................
ExpIain with an exampIe how a cIass impIements an interface.
When a class implements an interface, it has to implement the methods defined inside that interface. %his is enforced
at build time by the compiler..........................

Wby )ava uses Unicode
<<Previous Next>>
Java - Explain why Java uses Unicode. - March 14, 2010 at 05:16 AM by Vidya Sagar
Fxpluln why juvu uxex UnlcoJe.
%o enable a computer system for storing text and numbers which is understandable by humans, there should be a
code that transforms characters into numbers.
Unicode is a standard of defining the relevant code by using character encoding. Character encoding is the process
for assigning a number for every character. %he central objective of Unicode is to unify different language encoding
schemes in order to avoid confusion among computer systems that uses limited encoding standards such as ASC,
EBCDC etc.
Java Unicode:
%he evolution of Java was the time when the Unicode standards had been defined for very smaller character set.
Java was designed for using Unicode %ransformed Format (U%F)-16, when the U%F-16 was designed. %he 'char'
data type in Java originally used for representing 16-bit Unicode. Hence Java uses Unicode standard.
<<Previous Next>>
What is the purpose of setAutoCommit do?
A connection is in auto-commit mode by default which means every SQL statement is treated as a transaction and
will be automatically committed after it is executed...................
What is cIass Ioader? ExpIain the purpose of Bootstrap cIass Ioader.
Class loader finds and loads the class at runtime. Java class loader can load classes from across network or from
other sources like H%%P, F%P etc...............
What is the disadvantage of garbage coIIector?
Although garbage collector runs in its own thread, still it has impact on performance. t adds overheads since JVM
has to keep constant track of the object.................


Wbat are tbe different loops available in |ava?
<<Previous Next>>
Java - What are the different loops available in java? How do we choose the right loop for a specific job? -
March 14, 2010 at 05:16 AM by Vidya Sagar
hut ure the Jlfferent loopx uvulluble ln juvu? ow Jo we chooxe the rlght loop for u xpeclflc
job?
A loop is a set of statements that is supposed to repeat one or more times. Java supports 3 loops.
1. while loop %he block of statements will be repeated as long as the condition returns true. %he condition should
return false for exiting the loop. %he 'while' loop can be used when the number of iterations are not certain.
2. do . while Similar to the while loop. But the difference is the iteration takes place at least for once. %his is due
to the condition that is placed at the end of body of the loop. %he 'do..while' is apt when the loop certainly to execute
at least for one time. For example, to display a menu with several options to select. When the user does not want to
repeat, he should be given a provision soon after entering into the loop.
3. for loop Use for loop when the number of the iterations are known before entering into the body of the loop. t has
flexibility to assign variables before entering into the body of the loop and perform updation at the end of the loop.
4. for. each - Similar to for loop : perfectly apt for dealing with arrays. When each successive element is to be
accessed, use this loop. %he length or the indexes can not be used with this loop. Also useful to access a set of
collections such as List, Set etc.
<<Previous Next>>
How are Observer and ObservabIe used?
%he observable class represents an observable object.
%he object to be observed can be represented by sub-classing observable class.................
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events.......................


Primitive type
<<Previous Next>>
Java - Explain why we don't need to use new for variables of the primitive types, such as int or float - March
14, 2010 at 05:16 AM by Vidya Sagar
Fxpluln why we Jont neeJ to uxe new for vurlublex of the prlmltlve typex, xuch ux lnt or flout
%he key word 'new' is used for creation of objects. Primitive types are to use constants but not objects. Hence, new
key word is not used for primitive variables.
<<Previous Next>>
What are access modifiers in JAVA?
Public %he member with public modifier can be access by any other class.
Protected %he member with protected modifier can be accessed by the derived class only..............
Describe JDBC Architecture in brief.
Java application calls the JDBC library that loads a driver which talks to the database.....................


Wbat is finalize{]? s finalize{] similar to a destructor?
<<Previous Next>>
Java - What is finalize()? Is finalize() similar to a destructor? - March 14, 2010 at 05:16 AM by Vidya Sagar
hut lx flnullze()? Ix flnullze() xlmllur to u Jextructor?
%he 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 garbage collection
passes and reclaims the memory space. Choosing to use finalize() provides the ability for performing some important
cleanup action at the time of garbage collection.
%he destructor of C++ language will always destroy the objects. But Garbage collection is not destruction. n case,
some functionality needs to be performed prior to garbage collection. %he respective functionality must be hard coded
by the developer. As Java has no destructor or similar concept, the process need to be embedded into a method for
cleanup. %he finalize() method can be overridden to perform this cleanup.
<<Previous Next>>
What are the types of JDBC drivers?
JDBC-ODBC bridge plus ODBC driver, also called %ype 1, Native-AP, partly Java driver, also called %ype
2................
What is preinitiaIization of a servIet?
%he process of loading a servlet before any request comes in is called preloading or preinitializing a servlet...............


Wby does String define tbe equals{ ] metbod?
<<Previous Next>>
Java - Why does String define the equals( ) method? Can't I just use ==? - March 14, 2010 at 05:16 AM by
Vidya Sagar
hy Joex Strlng Jeflne the equulx( ) methoJ? unt I juxt uxe ==?
%he equals() method is defined in String class in order to test whether two strings values are same sequence of
characters. %he method is for exclusively testing string objects, but not any other objects.
%he operator '==' always compares the variables but not objects. %he 'reference variables' are compared with '==',
but not the objects. n terms of strings, the '==' operator always compares the references and not the 'character
sequences'.
<<Previous Next>>
What are transaction isoIation IeveIs in EJB?
%ransaction_read_uncommitted, %ransaction_read_committed, %ransaction_repeatable_read.................
ExpIain the difference between static and non-static member of a cIass.
A static field belongs to a class. %he objects of the class can not have the copy of these fields. %hese fields are
referred by the class name. Ex: Employee. company. Without creating an instance of a class, these fields can be
accessed....................


String ob|ects are immutable in |ava
<<Previous Next>>
Java - String objects are immutable in java. Explain how to create a string that can be changed- March 14,
2010 at 05:16 AM by Vidya Sagar
Strlng objectx ure lmmutuble ln juvu. Fxpluln how to creute u xtrlng thut cun be chungeJ
A string object that is created using "String class is immutable. %he characters of the object can not be changed /
modified. %here are some methods, such as split(), substring(), beginsWith() etc., modifies the strings, but returns
'new strings'. %he original string will remain same. %he changes are made only for the newly returned string objects.
n order to change the 'string' (Object of String class), it must be sent as a parameter to the StringBuffer /
StringBuilder constructor. %his string will be converted into the object of StringBuffer or StringBuilder object. %his is
the only way to change the string, but not the String class object itself.
<<Previous Next>>
ExpIain Java cIass Ioaders? ExpIain dynamic cIass Ioading?
%he classes are available to the JVM and are referenced by the name. After JVM starts, it introduces the classes into
it..................
What is synchronization and why is it important? Describe synchronization in respect to muItithreading.
Synchronization is the process of allowing threads to execute one after another..................
Can we pass a primitive type by reference in |ava? How
<<Previous Next>>
Java - Can we pass a primitive type by reference in java? How - March 14, 2010 at 05:16 AM by Vidya Sagar
un we puxx u prlmltlve type by reference ln juvu? ow
Primitive types can be passed by reference.
1. By storing the primitive type value in an array of single element and passing it.
2. By wrapping the primitive type into its corresponding wrapper class and passing it.
<<Previous Next>>
ExpIain with an exampIe how a cIass impIements an interface.
When a class implements an interface, it has to implement the methods defined inside that interface. %his is enforced
at build time by the compiler..........................
What is DatabaseMetaData?
DatabaseMetaData provides comprehensive information about the database. %his interface is implemented by the
driver vendors to allow the user to obtain information about the tables of a relational database as a part of JDBC
application...................

Wbat do you mean by tbe term signature in |ava?
<<Previous Next>>
Java - What do you mean by the term signature in java? - March 14, 2010 at 05:16 AM by Vidya Sagar
hut Jo you meun by the term xlgnuture ln juvu?
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.
Types of signatures:
A Simple signature is a single element which contains the name of the constructor and for a method preceded by the
return type.
A Full Signature has access specifiers for both constructors and methods and / or access modifiers, with or without
parameters for distinguishing among other methods or constructors.
<<Previous Next>>
ArrayIist vs. Vector
Arraylist's methods are not synchronized which means they are not thread safe. Vector's methods are synchronized
which means they are thread safe..............
What are inner cIasses?
Class that is nested within a class is called as inner class. %he inner class can access private members of the outer
class................


Static nested class vs. a non-static one
<<Previous Next>>
Java - Static nested class vs. a non-static one - March 14, 2010 at 05:16 AM by Vidya Sagar
Stutlc nexteJ cluxx vx. u non-xtutlc one
A static nested class can not directly access non-static methods or fields of an instance of its enclosing class. %hey
can be accessed by creating the object of the nested inner class. Where as non-static nested class can access to the
methods or fields of its enclosing class without creating their instance.
%he object creation of a static nested class must be qualified with its inner class. Where as non-static inner class
object will be created with its name alone.
Static inner class instance occupies less memory space. Where as the object of non-static inner class occupies more
space than static inner class.
<<Previous Next>>
What is Bytecode?
%he Java class file contains bytecode which is being interpreted by JVM. Bytecode is introduced in Java to provide
Java as platform independent language.................
ExpIain how to force garbage coIIection
Garbage collection can't be forced, it can explicitly be called using System.gc(), but there is not guarantee that GC
will be started immediately.............


plain wben we sbould make an instance variable private
<<Previous Next>>
Java - Explain when we should make an instance variable private - March 14, 2010 at 05:16 AM by Vidya
Sagar
Fxpluln when we xhoulJ muke un lnxtunce vurluble prlvute
An instance variable can be declared as private to promote information hiding. So that no other object can access
them.
<<Previous Next>>
Where shouId we put appIet cIass fiIes, and how to indicate their Iocation using the AppIet tag?
An applet class file may present in any of the folder. %he .class file name along with its current path( in which this
.html file is placed) is to be specified in the code attribute of <Applet> tag.................
What is the purpose of the enabIeEvents() method?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event.................
What is the difference between the iIe and RandomAccessiIe cIasses?
%he File class is used to perform the operations on files and directories of the file system of an operating system. %his
operating system is the platform for the java application that uses the File class objects.............
Uverridden metbods in )ava
<<Previous Next>>
Java - Overridden methods in Java - March 14, 2010 at 05:16 AM by Vidya Sagar
verrlJJen methoJx ln juvu
Overridden methods of super class in subclass allow a class to inherit and behave close enough. %o avoid naming
conflict and signature and type and number of parameters for a specific functionality that of a super class, the
overridden methods are utilized.
Every class is a descendent of the Object class. %his class contains toString() method which returns a String object
and its hash code. Most of the methods need to override this method.
For example the method System.out.println() will be overridden by toString() before displaying the result on the
screen. Another example: the Stack class overrides the method toString() when it pops an object.
<<Previous Next>>
String vs. StringBuffer cIass.
Latest answer: String class is immutable which means it can't be modified once declared.
StringBuffer is not immutable which means strings can be appended to the original string..............
What is Bytecode?
Latest answer: %he Java class file contains bytecode which is being interpreted by JVM. Bytecode is introduced in
Java to provide Java as platform independent language.................


s C++ access specifier called protected is similar to )ava's?
<<Previous Next>>
Java - Is C++ access specifier called protected is similar to Java's? - March 14, 2010 at 05:16 AM by Vidya
Sagar
Ix uccexx xpeclfler culleJ protecteJ lx xlmllur to juvux?
%he java access specifier 'protected' is placed proceeding the member of the class and the access control is
applicable only for that particular definition.
t is a distinct contrast to C++. n C++ the protected access specifier controls all the definitions, such as methods,
variables etc, until another access specifier comes along.
<<Previous Next>>
ExpIain how Java interacts with database. Give an exampIe to expIain it.
Java interacts with database using an AP called Java Database Connectivity. JDBC is used to connect to the
database, regardless the name of the database management software. Hence , we can say the JDBC is a cross-
platform AP..................
How are Observer and ObservabIe used?
All the objects which are the instances of the sub class Observable, maintains a list of observers..................
Wby sbould we catcb super class eceptions?
<<Previous Next>>
Java - Why should we catch super class exceptions? - March 14, 2010 at 05:16 AM by Vidya Sagar
hy xhoulJ we cutch xuper cluxx exceptlonx?
Every exception is represented by the instance of %hrowable or its subclasses. An object can carry the information for
the exception raising point to the exception handler which catches it. When an exception is thrown, JVM abruptly
completes the execution of expressions, statements, methods, invoking constructors etc. %he process is continued
until the process handler is found which indicates that particular exception by naming the super class of the class of
that exception.
<<Previous Next>>
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
What is the difference between preemptive scheduIing and time sIicing?
f a certain task is running and the scheduling method used is preemptive, and then if there is another task that has a
higher priority than the executing task.................
What is the difference between a static and a non-static inner cIass?
Like static methods and static members are defined in a class, a class can also be static. %o specify the static class,
prefix the keyword 'static' before the keyword 'class'............


Wby would we manually tbrow an eception?
<<Previous Next>>
Java - Why would we manually throw an exception? - March 14, 2010 at 05:16 AM by Vidya Sagar
hy woulJ we munuully throw un exceptlon?
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. n other words, in a situation where an exception is
predicted by the developers, then it can be explicitly thrown. %he key word 'throw' is used followed by the object of
the exception and it accepts only one parameter.
<<Previous Next>>
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events.......................
ExpIain the Java CoIIection framework? What are the benefits of the Java coIIection framework?
A collection is a set of heterogeneous objects. A framework makes the applications efficient, less hard coded, similar
implementation for various.................


Wbat is cbained eceptions in |ava?
<<Previous Next>>
Java - What is chained exceptions in java? - March 14, 2010 at 05:16 AM by Vidya Sagar
hut lx chulneJ exceptlonx ln juvu?
Once an application finds an exception, responds an exception by throwing another exception. t causes another
exception. Knowing an exception that causes another exception is very useful.
Chained exceptions helps in finding the root cause of the exception that occurs during application's execution. %he
methods that support chained exceptions are getCause(), initCause() and the constructors %hrowable(%hrowable),
%hrowable(String, %hrowable). %he reason / cause for the current exception is returned by the method getCause().
With initCause() method, the current exception's cause is set.
%he following example illustrates the use of chained exception.
try {
} catch (OException e) {
throw new OtherException(Other OException, e);.
}
When the OException is caught, a new OtherException is created with the original cause and the chain of exceptions
is thrown up to the exception handler at higher level.
<<Previous Next>>
ExpIain the compIete syntax for using the AppIet tag.
%he <Applet> tag has the following attributes:
Code: %o specify the .class
Width: %o indicate the width of the applet window at first time loading.
Height: %o indicate the height of the applet window at first time loading..................
What is a task's priority and how is it used in scheduIing?
A task's priority is an integer value. %his value is used to identify the relative order of execution with respect to other
tasks..................

Wben sbould we create our own custom eception classes?
<<Previous Next>>
Java - When should we create our own custom exception classes? - March 14, 2010 at 05:16 AM by Vidya
Sagar
hen xhoulJ we creute our own cuxtom exceptlon cluxxex?
%he 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 exception can be created by the developer. %his customization
gives the power to deal with application centric exceptions. For instance, in a banking application a customer tries to
withdraw amount which results in below the minimum balance. n this scenario, the developer needs to implement a
customized exception.
<<Previous Next>>
ExpIain the methods that controI a AppIet's on-screen appearance, update and paint.
%o refresh a page in an applet window without flashing, the update() method is to be overridden. t clears the
background of the component, before invoking paint()..................
Concrete cIass vs. Abstract cIass vs. Interface.
A concrete class has concrete methods, i.e., with code and other functionality. %his class a may extend an abstract
class or implements an interface...................
What is the disadvantage of garbage coIIector?
Although garbage collector runs in its own thread, still it has impact on performance. t adds overheads since JVM
has to keep constant track of the object.................


Wbat are primitive type wrappers classes?
<<Previous Next>>
Java - What are primitive type wrappers classes? Explain the purpose of primitive type wrapper classes -
March 14, 2010 at 05:16 AM by Vidya Sagar
hut ure prlmltlve type wrupperx cluxxex? Fxpluln the purpoxe of prlmltlve type wrupper
cluxxex
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.
A primitive type data element can have the advantages of an object by converting it into its corresponding wrapper
class object. %he wrapper classes are extensively used along with the Collection framework. %hus it enhances the
application's performance further.
Java 5.0 has additional wrapper classes known as atomic wrapper classes. %hey are available in
java.util.concurrent.atomic package. %hese classes are mutable. %hese can not be utilized as a replacement for the
wrapper classes. %hey provide atomic operations for addition, increment and assignment. %he atomic wrapper
classes are Atomicnteger, AtomicLong, AtomicBoolean, AtomicReference<v>.
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters..................
What is the purpose of the enabIeEvents() method?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................

Wby do you recommend tbat tbe main tbread be tbe last to finisb?
<<Previous Next>>
Java - Why do you recommend that the main thread be the last to finish? - March 14, 2010 at 05:16 AM by
Vidya Sagar
hy Jo you recommenJ thut the muln threuJ be the luxt to flnlxh?
n 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. t is a good programming practice to make it to run last to finish. %he application execution
starts by invoking main thread and the chain follows. So it is inevitable that all the threads complete their execution.
Soon after the completion of the execution the control returns to main thread. %hus the flow will not be missed. And it
is the main thread that starts first and also ends first.
<<Previous Next>>
What is the purpose of setAutoCommit do?
A connection is in auto-commit mode by default which means every SQL statement is treated as a transaction and
will be automatically committed after it is executed...................
What is Bootstrap, Extension and System CIass Ioader in Java?
%he Bootstrap class loader loads key Java classes. Bootstrap class loader loads the basic classes from Java library,
like java.*, javax.*. %his is the root in the class loader hierarchy...................


Wby does )ava bave two ways to create cbild tbreads?
<<Previous Next>>
Java - Why does Java have two ways to create child threads? Which way is better? - March 14, 2010 at 05:16
AM by Vidya Sagar
hy Joex juvu huve two wuyx to creute chllJ threuJx? hlch wuy lx better?
Java threads can be created graciously in two ways: implementing the Runnable interface and extending %hread
class.
Extending the class inherits the methods and data members, fields from the class %read. n this process only one
class can be inherited from the parent class %hread.
mplementing Runnable interface overcomes the limitation of inheriting from only one parent class %hread. Using
Runnable interface, lays a path to ground work of a class that utilizes threads. %he advantage is a class can extend
%hread class and also implements the Runnable interface, if required. %he Runnable interface is set for implementing
a thread and the class that implements the interface performs all the work.
<<Previous Next>>
What are access modifiers in JAVA?
Public %he member with public modifier can be access by any other class.
Protected %he member with protected modifier can be accessed by the derived class only..............
What is LinkedList cIass?
LinkedList class implements the List interface. n addition to the List operations, the LinkedList class supports the
operations of inserting elements................
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events........................


Tips on effectively using Multitbreading
<<Previous Next>>
Java - Tips on effectively using Multithreading to improve the efficiency of my programs - March 14, 2010 at
05:16 AM by Vidya Sagar
1lpx on effectlvely uxlng MultlthreuJlng to lmprove the efflclency of my progrumx
n multiple processor systems, a large algorithm will split the process into threads. So that different processors can
handle different threads. Multithreading can greatly help the external lookups like JDBC connections, serializing the
objects, persisting data in file streams and so on. While the code waits for the data from the database, the CPU would
be free and can handle other task. With multiprocessor systems, these tasks are multiplied as there are multiple
processors. %hus multiple threads improve the program / application efficiency.
<<Previous Next>>
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
ExpIain the Java CoIIection framework? What are the benefits of the Java coIIection framework?
A collection is a set of heterogeneous objects. A framework makes the applications efficient, less hard coded, similar
implementation for various.................
enumerations vs final variables in |ava
<<Previous Next>>
Java - enumerations vs final variables in java - March 14, 2010 at 05:16 AM by Vidya Sagar
enumerutlonx vx flnul vurlublex ln juvu
Enumeration is type safe. Where as final variables are not.
Enumeration supports to have a blend of various values. Where as final variables does not support multiple values.
Enumeration constants can be names. Where as final constants can not be named.
<<Previous Next>>
String vs. StringBuffer cIass.
String class is immutable which means it can't be modified once declared.
StringBuffer is not immutable which means strings can be appended to the original string..............
Define IsoIation.
solation ensures one transaction does not interfere with another. %he isolation helps when there are concurrent
transactions...............


Uutput to an applet's window
<<Previous Next>>
Java - Is it possible for a method other than paint() or update() to output to an applet's window? Explain
how - March 14, 2010 at 05:16 AM by Vidya Sagar
Ix lt poxxlble for u methoJ other thun pulnt() or upJute() to output to un uppletx wlnJow?
Fxpluln how
es it is possible for a method other than paint() or update() to output an applet's window. t is mandatory to obtain a
graphics context by invoking getGraphics() method, that is defined Component class. Later use it to output to the
window.
Create an instance of the class Bufferedmage. Use the method getGraphics(), which returns the Graphics object.
%he methods drawOval(), setColor() can be used as
graphics.drawOval(150,150,120,50);
graphics.setColor(Color.green);
<<Previous Next>>
ExpIain how Java interacts with database. Give an exampIe to expIain it.
Java interacts with database using an AP called Java Database Connectivity. JDBC is used to connect to the
database, regardless the name of the database management software. Hence , we can say the JDBC is a cross-
platform AP..................
Concrete cIass vs. Abstract cIass vs. Interface.
A concrete class has concrete methods, i.e., with code and other functionality. %his class a may extend an abstract
class or implements an interface....................
Wbat is byte code?
<<Previous Next>>
Java - What is byte code and why is it important to Java's use for Internet programming? - March 14, 2010 at
05:16 AM by Vidya Sagar
hut lx byte coJe unJ why lx lt lmportunt to juvux uxe for Internet progrummlng?
%he compiled Java source code is known as byte code. Java compiler generates the byte code.
%he byte code can run on any platform / machine regardless of the system's architecture. %he WORA feature is
implemented with byte code. %he byte code can be used for internet applications in which security is a major issue.
Byte code is device independent and allows loading classes dynamically.
As byte code is device independent and internet applications are run on various machines, using various platforms
(OS) and on various browsers. %his feature of byte code allows the web applications to run on various platforms, on
various browsers on different infrastructures.
<<Previous Next>>
What is ResuItSetMetaData?
ResultSetMetaData is an object that gets information about the types and properties of the columns in a ResultSet
object...............
ExpIain the Java CoIIection framework? What are the benefits of the Java coIIection framework?
A collection is a set of heterogeneous objects. A framework makes the applications efficient, less hard coded, similar
implementation for various................
ExpIain the difference between StringBuiIder and StringBuffer cIass.
StringBuilder is unsynchronized whereas StringBuffer is synchronized. So when the application needs to be run only
in a single thread then it is better to use StringBuilder. StringBuilder is more efficient than StringBuffer............


ange and bebavior of its primitive types
<<Previous Next>>
Java - Why does Java strictly specify the range and behavior of its primitive types? - March 14, 2010 at 05:16
AM by Vidya Sagar
hy Joex juvu xtrlctly xpeclfy the runge unJ behuvlor of ltx prlmltlve typex?
Java strictly specifies the ranges for primitive values. %he selection of values in integer or floating point types differs
based on the requirement of an application. Developers need not always use int type to handle any integer values. By
having the ranges, Java allows developers to utilize the facilities on primitive types in wise manner. For example to
use the integer constant 39, it is not wise to represent long or int or even short as it is available in byte type and
occupies 8 bits of memory space. By using it as int type, 32 bits of memory space need to be used. Hence there will
be a performance issue. %hus the range of primitive types plays a vital role in a Java application performance.
<<Previous Next>>
String vs. StringBuffer cIass.
String class is immutable which means it can't be modified once declared.
StringBuffer is not immutable which means strings can be appended to the original string..............
What is Bytecode?
%he Java class file contains bytecode which is being interpreted by JVM. Bytecode is introduced in Java to provide
Java as platform independent language.................
Wbat is )ava's cbaracter type?
<<Previous Next>>
Java - What is Java's character type? - March 14, 2010 at 05:16 AM by Vidya Sagar
hut lx juvux churucter type, unJ how Joex lt Jlffer from the churucter type uxeJ by muny
other progrummlng lunguugex?
%he char data type in Java is a single 16-bit Unicode character. t represents a character that could be any one of the
world languages. Other programming languages support 256 characters in general, and most of them represent
ASC / EBCDC characters. %hey do not support world language characters.
<<Previous Next>>
What is preinitiaIization of a servIet?
%he process of loading a servlet before any request comes in is called preloading or preinitializing a servlet..............
Define IsoIation.
solation ensures one transaction does not interfere with another. %he isolation helps when there are concurrent
transactions...............

ifference between tbe prefi and postfi forms
<<Previous Next>>
Java - Difference between the prefix and postfix forms of the increment operator - March 14, 2010 at 05:16 AM
by Vidya Sagar
Fxpluln the Jlfference between the preflx unJ poxtflx formx of the lncrement operutor
%he prefix operator ++ adds one to its operand / variable and returns the value before it is assigned to the variable. n
other words, the increment takes place first and the assignment next.
%he postfix operator ++ adds one to its operand / variable and returns the value only after it is assigned to the
variable. n other words, the assignment takes place first and the increment next.
<<Previous Next>>
Where shouId we put appIet cIass fiIes, and how to indicate their Iocation using the AppIet tag?
An applet class file may present in any of the folder. %he .class file name along with its current path( in which this
.html file is placed) is to be specified in the code attribute of <Applet> tag.................
How can we handIe SQL exception in Java?
SQL Exception is associated with a failure of a SQL statement. %his exception can be handled like an ordinary
exception in a catch block...................
String metbods indeUf{] and lastndeUf{]
<<Previous Next>>
Java - Difference between the String methods indexOf( ) and lastIndexOf( ) - March 14, 2010 at 05:16 AM by
Vidya Sagar
lfference between the Strlng methoJx lnJexf( ) unJ luxtInJexf( )
%he method indexOf() returns the first occurrence (index) of a given character or a combination as parameter in a
given string.
%he method lastndexOf() returns the last occurrence (last index) of a given character or combination in a given
string.
<<Previous Next>>
Difference between a pubIic and a non-pubIic cIass.
A class with access specifier 'public' can be accessed across the packages. A package is like a folder in GU based
operating systems. For example, the "public class String class is a public class which can be accessed across the
packages..................
What is the purpose of finaIization?
Finalization is the facility to invoke finalized() method. %he purpose of finalization is to perform some action before the
objects get cleaned up..............

ifference between protected and default access
<<Previous Next>>
Java - difference between protected and default access - March 14, 2010 at 05:16 AM by Vidya Sagar
lfference between protecteJ unJ Jefuult uccexx
%he default access specifier is one which is not specified with a key word. f no access specifier (any one of private,
protected, public) is mentioned it is known as the default access specifier. %he methods, variables of class without
access specifier can be accessed by classes, methods within the package in which they were declared.
%he protected access specifier also has the same scope that of default access specifier and can be accessed in all
subclasses of the protected class across packages i.e., packages other than the package in which the protected
member is declared / defined.
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters..................
What's the difference between servIets and appIets?
Servlets executes on Servers while Applets executes on browser, Unlike applets, servlets have no graphical user
interface...................


Ways tbat tbe members of a package can be used by otber packages
<<Previous Next>>
Java - Explain the two ways that the members of a package can be used by other packages - March 14, 2010
at 05:16 AM by Vidya Sagar
uyx thut the memberx of u puckuge cun be uxeJ by other puckugex
%here 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.
%wo, the access level need to be decided by the developer for the classes or methods defined by him/her.
<<Previous Next>>
What is an AppIet?
An applet is a small server side application that can be loaded and controlled on the browser by the client
application...............
What are transaction isoIation IeveIs in EJB?
%ransaction_read_uncommitted, %ransaction_read_committed, %ransaction_repeatable_read................
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events........................


plain )ava's delegation event model
<<Previous Next>>
Java - Explain Java's delegation event model - March 14, 2010 at 05:16 AM by Vidya Sagar
Fxpluln juvux Jelegutlon event moJel
%he event model is based on the Event Source and Event Listeners. Event Listener is an object that receives the
messages / events. %he Event Source is any object which creates the message / event. %he Event Delegation model
is based on %he Event Classes, %he Event Listeners, Event Objects.
%here are three participants in event delegation model in Java;
- Event Source the class which broadcasts the events
- Event Listeners the classes which receive notifications of events
- Event Object the class object which describes the event.
An event occurs (like mouse click, key press, etc) which is followed by the event is broadcasted by the event source
by invoking an agreed method on all event listeners. %he event object is passed as argument to the agreed-upon
method. Later the event listeners respond as they fit, like submit a form, displaying a message / alert etc.
<<Previous Next>>
String object is immutabIe, ExpIain.
%his means once you have created String object and assigned a value, you can't change the value of the
object.................
ExpIain the difference between static and non-static member of a cIass.
A static field belongs to a class. %he objects of the class can not have the copy of these fields. %hese fields are
referred by the class name. Ex: Employee. company. Without creating an instance of a class, these fields can be
accessed....................
escribe tbe assert keyword
<<Previous Next>>
Java - Describe the assert keyword - March 14, 2010 at 05:16 AM by Vidya Sagar
excrlbe the uxxert keyworJ
%he programmer assumes certain code while developing when handling exceptions. For example, a number is
passed as parameter to a method and it is to be validated whether it is positive. %he assumption is to be validated
during testing and debugging. n general, this issue is handled by coding with if like
if(number>0) { // some code }
else { // display error message}.

Assertion is helpful for saving time to write code for exception handling. %he above coding can be altered by the
following:
private void method(int number) {
assert (number >= 0) //throws an assertion error.
// some code
}
%he code assert(number>0) will be passed only when number is positive. An assertion error will be thrown if the value
of number is negative.
<<Previous Next>>
ExpIain the difference between static and non-static member of a cIass.
A static field belongs to a class. %he objects of the class can not have the copy of these fields. %hese fields are
referred by the class name. Ex: Employee. company. Without creating an instance of a class, these fields can be
accessed...................
What is an abstract cIass? ExpIain its purpose.
A class with one of more abstract methods is called an Abstract class. An abstract method is a method with signature
with out code in it................

Wby a native metbod migbt be useful
<<Previous Next>>
Java - Explain why a native method might be useful to some types of programs - March 14, 2010 at 05:16 AM
by Vidya Sagar
Fxpluln why u nutlve methoJ mlght be uxeful to xome typex of progrumx
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 in another language, Java
native methods are needed. %he native AP implementations allow all the Java applications to access the native
functionality in a safe and platform independent mode. %he JN framework allows the native method utilization
through Java objects in the similar fashion which Java code utilizes these objects. %he JN is an interface for code
written in other languages. Certain time critical calculations like complicated mathematical equations as native code
execution is faster than JVM code.
<<Previous Next>>
What is Bootstrap, Extension and System CIass Ioader in Java?
%he Bootstrap class loader loads key Java classes. Bootstrap class loader loads the basic classes from Java library,
like java.*, javax.*. %his is the root in the class loader hierarchy.................
ExpIain the concepts of Exceptions in Java.
Exceptions are errors that occur at runtime and disrupt the normal flow of execution of instructions in a
program...............
What is the disadvantage of garbage coIIector?
Although garbage collector runs in its own thread, still it has impact on performance. t adds overheads since JVM
has to keep constant track of the object.................


Use of sbift operator in )ava
<<Previous Next>>
Java - Explain the use of shift operator in Java. Can you give some examples? - March 14, 2010 at 05:16 AM
by Vidya Sagar
Fxpluln the uxe of xhlft operutor ln juvu. un you glve xome exumplex?
Using shift operators in Java we can
1. nteger division and multiplication is done faster.
Example
84547 * 4 can be done by using 84547 << 2

or

84547 / 2 can be done by using 84547 >> 1
2. %o reassemble byte streams into int values
3. %o accelerate operations with graphics as Red, Green and Blue colors coded by separate bytes.
<<Previous Next>>
Difference between a pubIic and a non-pubIic cIass.
A class with access specifier 'public' can be accessed across the packages. A package is like a folder in GU based
operating systems. For example, the "public class String class is a public class which can be accessed across the
packages..................
What is Entity Bean?
%he entity bean is used to represent data in the database. Entity beans provide a component model that
allows.....................
eed of wrappers like nteger, Boolean for int, boolean
<<Previous Next>>
Java - Why do we need wrappers like Integer, Boolean for int, boolean in Java? - March 14, 2010 at 05:16 AM
by Vidya Sagar
hy Jo we neeJ wrupperx llke Integer, Booleun for lnt, booleun ln juvu?
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. As the instances of wrapper classes are
created, they can be persisted in the collection classes and pass them to methods as a collection.
<<Previous Next>>
Advantages and disadvantages of interfaces.
Latest answer: nterfaces are mainly used to provide polymorphic behavior, nterfaces function to break up the
complex designs and clear the dependencies between objects.................
What are access modifiers in JAVA?
Public %he member with public modifier can be access by any other class.
Protected %he member with protected modifier can be accessed by the derived class only.............
How are Observer and ObservabIe used?
%he observable class represents an observable object.
%he object to be observed can be represented by sub-classing observable class..................
Array vs ArrayList vs LinkedList vs Vector in |ava
<<Previous Next>>
Java - Array vs ArrayList vs LinkedList vs Vector in java - March 14, 2010 at 05:16 AM by Vidya Sagar
Arruy vx ArruyIlxt vx IlnkeJIlxt vx Vector ln juvu
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.
ArrayList has group of objects. Array it treated as an object.
LinkedList vs Vector:
A vector is a growable array which can store many objects of different classes.
A linked list is a linear list where each item has a link to the next item in the list. t can be used to implement queue or
stack operations.
Array list is better than linked list for accessing elements. %o search the 1000th element, array list can perform it in a
jiffy. While Linked list need to search / crawl through from the first element.
Linked list is better than array list to perform insertion and deletion operations at arbitrary locations.
<<Previous Next>>
What are transaction isoIation IeveIs in EJB?
%ransaction_read_uncommitted, %ransaction_read_committed, %ransaction_repeatable_read.................
What is JSP?
JSP is a technology that returns dynamic content to the Web client using H%ML, XML and JAVA
elements...................

efine Autoboing witb an eample
<<Previous Next>>
Java - Define Autoboxing with an example - March 14, 2010 at 05:16 AM by Vidya Sagar
eflne Autoboxlng wlth un exumple
%he automatic conversion of primitive int type into a wrapper class object is called autoboxing. t does not require to
type cast the int value. %he modification of primitive wrapper objects is done directly. %he following example illustrates
autoboxing:
int number;
nteger intObject;
number = 1;
intObject = 2;
number = intObject;
intObject = number;
<<Previous Next>>
What is the purpose of the enabIeEvents() method?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
ExpIain the Java CoIIection framework? What are the benefits of the Java coIIection framework?
A collection is a set of heterogeneous objects. A framework makes the applications efficient, less hard coded, similar
implementation for various.................

Can )ava communicate witb ActiveX ob|ects?
<<Previous Next>>
Java - Can Java communicate with ActiveX objects? - March 14, 2010 at 05:16 AM by Vidya Sagar
un juvu communlcute wlth ActlveX objectx? Fxpluln how
Java can communicate with ActiveX objects by using Bridge2Java from BM. Bridge2Java is a tool for allowing the
java applications for communicating with ActiveX objects. %he integration of ActiveX into Java environment is easy. t
is achieved by using JN and COM technology and the ActiveX object is treated as a java object by Bridge2Java.
A proxy generating tool is required which creates the Java proxies from the ActiveX control typelib. Later there
proxies are utilized for allowing a java application to communicate with the ActiveX object.
<<Previous Next>>
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events.......................
What is ResuItSetMetaData?
ResultSetMetaData is an object that gets information about the types and properties of the columns in a ResultSet
object...............
Wbat is CLASSPATH variable? Wbat is default classpatb?
<<Previous Next>>
Java - What is CLASSPATH variable? What is default classpath? - March 14, 2010 at 05:16 AM by Vidya
Sagar
hut lx IASSPA1 vurluble? hut lx Jefuult cluxxputh?
CLASSPA%H is an environment variable that communicates JVM and other java applications for finding the java
language class libraries, including the developer's class library. t is set by setenv command like
setenv CLASSPA%H path1:class2 ..
%he class libraries of java language that the CLASSPA%H points to are JDK classes in lib directory and or any user
defined classes.
%he default CLASSPA%H is .:bin/../classes:bin/../lib/classes.zip
<<Previous Next>>
Significance of inaIize method.
%he Finalize method of an object is called when GC is about to clean up the object. We can keep clean up code in
the finalize block...............
What is JAR fiIe?
JAR is a Java Archived file which allows many files to be stored. All applets and classes can be stored in a JAR file
thereby reducing the size....................

plain bow to convert any )ava Ub|ect into byte array
<<Previous Next>>
Java - Explain how to convert any Java Object into byte array - March 14, 2010 at 05:16 AM by Vidya Sagar
Fxpluln how to convert uny juvu bject lnto byte urruy
1. Create an object of ByteArrayOutputStream class.
ByteArrayOutputStream bStream = new ByteArrayOutputStream();
2. Create an object of ObjectOutputStream object and send the reference of ByteArrayOutPutStream object as
parameter of ObjectOutputStream constructor.
ObjectOutputStream oStream = new ObjectOutputStream( bStream );
3. Place any object in the method writeObject() of ObjectOutputStream
oStream.writeObject ( obj );
4. nvoke toByteArray() method of ByteArrayOutputStream reference
byte[] byteVal = bStream. toByteArray();
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
f a certain task is running and the scheduling method used is preemptive, and then if there is another task that has a
higher priority than the executing task..................
How are Observer and ObservabIe used?
%he observable class represents an observable object.
%he object to be observed can be represented by sub-classing observable class.................

plain bow to convert bytes[] into File ob|ect
<<Previous Next>>
Java - Explain how to convert bytes[] into File object - March 14, 2010 at 05:16 AM by Vidya Sagar
Fxpluln how to convert bytex[j lnto Flle object
1. Create a File object.
File file = new File("path and file name here);.
2. Create a byte array with elements.
byte barray[] = { elements here };
2. Place the File object as parameter for FileOutputStream constructor.
FileOutputStream fostrm = new FileOutputStream(file);
3. nvoke the write method of FileOutputStream by sending the byte array as parameter.
fostrm.write(bArray);
<<Previous Next>>
ExpIain with an exampIe how a cIass impIements an interface.
Latest answer: When a class implements an interface, it has to implement the methods defined inside that interface.
%his is enforced at build time by the compiler..........................
What is the difference between the iIe and RandomAccessiIe cIasses?
Latest answer: %he OS based file system services such as creating folders, files, verifying the permissions,
changing file names etc., are provided by the java.io.File class...................
)avaSpaces tecbnology vs. database
<<Previous Next>>
Java - JavaSpaces technology vs. database - March 14, 2010 at 05:16 AM by Vidya Sagar
juvuSpucex technology vx. Jutubuxe
Java spaces is a technology with powerful high-level tool for the development of distributed and collaborative
applications. A simple AP is provided based on the network shared space for developing sophisticated distributed
applications.
%he following are the key differences between JavaSpaces technology and database:
- RDBMS understands the data stored and manipulated directly by using SQL and DML. JavaSpaces persists the
entries only by the type and serialized form(objects serialization) of each field.
- Nearly transparent memory is provided for storing data as object-oriented image by object databases. JavaSpaces
do not provide a nearly transparent persistent layer. %hey perform only on the copies of the entries.
<<Previous Next>>
ExpIain cIass vs. instance with exampIe using java.
A class is a program construct which encapsulates data and operations on data. t is a blue print of an
object..................
What is Map and SortedMap Interface?
A map is an object that maps the keys to values. Map provides the facility of storing elements without duplicate keys.
%he Map interface does not provide the sorted order of key and value pairs...............


Metbods for accessing system properties about tbe )ava virtual macbine
<<Previous Next>>
Java - Explain the methods for accessing system properties about the Java virtual machine - March 14, 2010
at 05:16 AM by Vidya Sagar
Fxpluln the methoJx for uccexxlng xyxtem propertlex ubout the juvu vlrtuul muchlne
%he system properties are accessed by the method System.getProperties(). %his method returns a Properties object.
By using the list() method of Properties, all the system properties can be viewed. %he following code snippet
illustrates displaying the system properties.
Properties props;
props = System.getProperties();
props.list(System.out);
<<Previous Next>>
What is the difference between the iIe and RandomAccessiIe cIasses?
%he File class is used to perform the operations on files and directories of the file system of an operating system. %his
operating system is the platform for the java application that uses the File class objects..............
ExpIain the difference between static and non-static member of a cIass.
A static field belongs to a class. %he objects of the class can not have the copy of these fields. %hese fields are
referred by the class name. Ex: Employee. company. Without creating an instance of a class, these fields can be
accessed....................


ifference between add{] and addlement{] in Vector
<<Previous Next>>
Java - What is difference between add() and addElement() in Vector? - March 14, 2010 at 05:16 AM by Vidya
Sagar
hut lx Jlfference between uJJ() unJ uJJFlement() ln Vector?
%he add() methods inserts an element at a given position of the vector.
%he addElement () method adds an object at the end of the vector and increases the size of the vector by one.
<<Previous Next>>
What is LinkedList cIass?
LinkedList class implements the List interface. n addition to the List operations, the LinkedList class supports the
operations of inserting elements................
What is Bootstrap, Extension and System CIass Ioader in Java?
%he Bootstrap class loader loads key Java classes. Bootstrap class loader loads the basic classes from Java library,
like java.*, javax.*. %his is the root in the class loader hierarchy..................


Wbat is difference between sets and lists?
<<Previous Next>>
Java - What is difference between sets and lists? - March 14, 2010 at 05:16 AM by Vidya Sagar
hut lx Jlfference between xetx unJ llxtx?
Sets can have unique values.
Lists can have duplicate values.

Set is an unordered collection.
List is an ordered collection.
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters..................
Define IsoIation.
solation ensures one transaction does not interfere with another. %he isolation helps when there are concurrent
transactions................
Wbat is fail-fast iterator in )ava? Wbat is it used for?
<<Previous Next>>
Java - what is fail-fast iterator in Java? What is it used for? - March 16, 2010 at 15:05 PM by Vidya Sagar
whut lx full-fuxt lterutor ln juvu? hut lx lt uxeJ for?
%he unsynchronized collections and their modifications, iterations are termed as 'fail-fast' iterators. An iterator that
implements terable interface and looping through it will create an iterator. %his iterator returns the iterator method of
this class, which named as 'fail-fast' if, the given set is updated at any given point of time after the creation of the
iterator, through the iterator's remove method and throws a ConcurrentModificationException.
<<Previous Next>>
What is Bootstrap, Extension and System CIass Ioader in Java?
%he Bootstrap class loader loads key Java classes. Bootstrap class loader loads the basic classes from Java library,
like java.*, javax.*. %his is the root in the class loader hierarchy..................
What is Connection pooIing?
A Connection pooling is a technique of reusing active database connections instead of creating a new connection
with every request.............

Store and retrieve serialized ob|ects
<<Previous Next>>
Java - How to store and retrieve serialized objects to and from a file in Java? - March 16, 2010 at 15:05 PM by
Vidya Sagar
ow to xtore unJ retrleve xerlullzeJ objectx to unJ from u flle ln juvu?
%he object's current state can be persisted and retrieved by using the concept known as 'serialization'. %his is done
on an object to a stream. %he stream would function as a container for the object. %he persistent container, like a file
on disk, allows the data of an object to be stored after the current session is completed. %he interface 'Serializable'
would support to perform the operations along with ObjectOutputStream and ObjectnputStream class objects. %he
method to write data is writeObject() and the method to retrieve object's data is readObject().
<<Previous Next>>
What is casting? What are the different types of Casting?
%ype casting: Explicit conversion between incompatible types ( or ) changing entities from one data type to another
data type....................
What is LinkedList cIass?
LinkedList class implements the List interface. n addition to the List operations, the LinkedList class supports the
operations of inserting elements................
Wbat is relation between )AXP and Xerces?
<<Previous Next>>
Java - What is relation between JAXP and Xerces? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx relutlon between jAXP unJ Xercex?
Xerces is a group of libraries for parsing, serializing, validating and manipulating XML. t implements a number of
standard APs for XML parsing, which includes DOM and SAX.
JAXP is an AP which is more accurately known as abstraction layer. JAXP provides an easy access for using SAX
and DOM for dealing with some difficult tasks. Certain vendor-specific tasks could be accessed in a vendor-neutral
way.
JAXP and Xerces are similar in playing a role to deal with database like Oracle's JDBC driver for Oracle.
<<Previous Next>>
What is the purpose of setAutoCommit do?
A connection is in auto-commit mode by default which means every SQL statement is treated as a transaction and
will be automatically committed after it is executed...................
What is Bootstrap, Extension and System CIass Ioader in Java?
%he Bootstrap class loader loads key Java classes. Bootstrap class loader loads the basic classes from Java library,
like java.*, javax.*. %his is the root in the class loader hierarchy..................

Wbat type of garbage collection does a System.gc{] do?
<<Previous Next>>
Java - What type of garbage collection does a System.gc() do? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut type of gurbuge collectlon Joex u Syxtem.gc() Jo?
Among various types of garbage collections, the System.gc() performs an explicit collection of garbage calls. %he
other garbage collection types are:
O %hroughput Collector
O Concurrent Low Pause Collector
O ncremental Low Pause Collector
<<Previous Next>>
What are different types of inner cIasses?
%here are 4 types of inner classes - Member inner class, Local inner class, Static inner class and Anonymous inner
class.................
Difference between an abstract cIass and an interface and when shouId you use them
An abstract has one or more abstract methods apart from concrete methods. All the abstract methods must be
overridden by its subclasses..................

Wben do need to use reflection feature in )ava?
<<Previous Next>>
Java - When do I need to use reflection feature in Java? - March 16, 2010 at 15:05 PM by Vidya Sagar
hen Jo I neeJ to uxe reflectlon feuture ln juvu?
Reflection feature in java allows an executing java program for introspecting upon itself. t also allows for
manipulating internal properties of the program. For instance, it is possible to obtain the names of all members of a
Java class and displaying them, using reflection feature. t reflects the classes, objects and interfaces in the
concurrent JVM. %his AP can be used for writing certain developing tools such as debuggers, class browsers, and
GU builders.
%he following are the operations which can be done by reflection feature:
- Determine the class of the object
- Finding the methods declaration, constants of an interface.
- Creating an instance of a class without knowing the name until runtime
- Values of an object's fields can get and set, even the field name is not known.
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters..................
ExpIain Java cIass Ioaders? ExpIain dynamic cIass Ioading?
%he classes are available to the JVM and are referenced by the name. After JVM starts, it introduces the classes into
it.................
What is the Vector cIass?
%he Vector class implements an incremental array of objects.
%he vector components can be accessed using an integer index.
%he size of a Vector increases or decreases as needed to accommodate the items..........
plain bow to measure time in nanoseconds.
<<Previous Next>>
Java - Explain how to measure time in nanoseconds. - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln how to meuxure tlme ln nunoxeconJx.
%ime is measured in nanoseconds by using the method nano%ime() method. %his method returns the current value of
the most precise system timer available in nanoseconds. t is used for measuring elapsed time.
For example, to measure how long some code takes to execute:
long start%ime = System.nano%ime();
long estimated%ime = System.nano%ime() - start%ime;
%he above code snippet returns the current value of the time in nanoseconds.
%he value returned by System.nano%ime() is platform dependent.
<<Previous Next>>
Significance of inaIize method.
Latest answer: %he Finalize method of an object is called when GC is about to clean up the object. We can keep
clean up code in the finalize block...............
What is the purpose of finaIization?
Latest answer: Finalization is the facility to invoke finalized() method. %he purpose of finalization is to perform some
action before the objects get cleaned up..............

)ava Tbread: run{] vs start{] metbod
<<Previous Next>>
Java - Java Thread: run() vs start() method - March 16, 2010 at 15:05 PM by Vidya Sagar
juvu 1hreuJ: run() vx xturt() methoJ
%he method start() invokes the run() method.
f the run() method of two threads invoked separately, they will execute one after the other.
f the start() method is used on two threads, both threads runs simultaneously.
%he start() method invokes the run() method asynchronously, where as the run() methods run synchronously.
<<Previous Next>>
this vs. super keyword.
this refers to current object instance.
super refers to the member of superclass of the current object instance..................
String vs. StringBuffer cIass.
String class is immutable which means it can't be modified once declared.
StringBuffer is not immutable which means strings can be appended to the original string...............
Wbat is )ava solates and wby do we need it?
<<Previous Next>>
Java - What is Java Isolates and why do we need it? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx juvu Ixolutex unJ why Jo we neeJ lt?
Java solates is an AP. t provides a mechanism to manage Java application life cycles which are isolated from each
other. %hey can potentially share the underlying implementation resources. t is a deploying means for new Java
implementation features which enable and enhance the scalability while providing an alternative for ad hoc control
schemes. %here are different implementations for different levels of isolations. All the implementations must
guarantee the isolation of the Java state. Separation of JN state and separation of process state are additional forms
of isolation.
%he selection of implementation specific features within the context of this AP could be through the combination of
vendor specific and standard command line arguments and properties.
<<Previous Next>>
ExpIain the concepts of Exceptions in Java.
Exceptions are errors that occur at runtime and disrupt the normal flow of execution of instructions in a
program...............
What is the purpose of setAutoCommit do?
A connection is in auto-commit mode by default which means every SQL statement is treated as a transaction and
will be automatically committed after it is executed...................

System properties tbat applets are allowed to read
<<Previous Next>>
Java - What are the system properties that applets are allowed to read by default? - March 16, 2010 at 15:05
PM by Vidya Sagar
hut ure the xyxtem propertlex thut uppletx ure ulloweJ to reuJ by Jefuult?
%he following are the system properties that Java applets read by default with System.getProperty() method:
- java.version
- java.vendor
- java.vendor.url
- java.class.version
- os.name
- os.arch
- os.version
- file.separator
- path.separator
- line.separator
<<Previous Next>>
What is JDBC driver?
%he JDBC Driver provided by the JDBC AP, is a vendor-specific implementations of the abstract classes. %he driver
is used to connect to the database..............
What is cIass Ioader? ExpIain the purpose of Bootstrap cIass Ioader.
Class loader finds and loads the class at runtime. Java class loader can load classes from across network or from
other sources like H%%P, F%P etc................
Wbat is |vmstat?
<<Previous Next>>
Java - What is jvmstat? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx jvmxtut?
%he jvmstat is a technology for adding light weight performance, configuration instrumentation to the HotSpot JVM.
%he jvmstat provides a set of APs and tools to monitor the performance of the HotSpot JVM in the production
environments.
%he tools are jvmstat-for general purpose command line tool, jvmps-a java process list tool and visualgc-a
generational heap visualization.
%he jvmstat supports remote monitoring with the support of RM server application.
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
f a certain task is running and the scheduling method used is preemptive, and then if there is another task that has a
higher priority than the executing task..................
What are different types of inner cIasses?
%here are 4 types of inner classes - Member inner class, Local inner class, Static inner class and Anonymous inner
class.................

How to implement singleton design pattern in struts
<<Previous Next>>
Java - Describe how to implement singleton design pattern in struts. - March 16, 2010 at 15:05 PM by Vidya
Sagar
excrlbe how to lmplement xlngleton Jexlgn puttern ln xtrutx.
A singleton implementation is done using action class in struts framework. t performs as a front controller and every
request will go through it. Also, the logging mechanism is easier. %his can be achieved without authoring Log4j class
over and over in each and every servlet.
<<Previous Next>>
What's the difference between servIets and appIets?
Servlets executes on Servers while Applets executes on browser, Unlike applets, servlets have no graphical user
interface..................
What is the purpose of setAutoCommit do?
A connection is in auto-commit mode by default which means every SQL statement is treated as a transaction and
will be automatically committed after it is executed...................

ifference between lengtb and lengtb{]
<<Previous Next>>
Java - Difference between length and length() - March 16, 2010 at 15:05 PM by Vidya Sagar
lfference between length unJ length()? Fxpluln wlth un exumple for euch
%he '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.
<<Previous Next>>
What is cIass Ioader? ExpIain the purpose of Bootstrap cIass Ioader.
Class loader finds and loads the class at runtime. Java class loader can load classes from across network or from
other sources like H%%P, F%P etc................
Define cIass and object. ExpIain them with an exampIe using java.
Class: A class is a program construct which encapsulates data and operations on data. n object oriented
programming, the class can be viewed as a blue print of an object.....................


ifference between >> and >>>
<<Previous Next>>
Java - Difference between >> and >>> - March 16, 2010 at 15:05 PM by Vidya Sagar
lfference between >> unJ >>>
%he >> is right shift operator. t shifts bits towards right.
For example: 5 >> 1 returns 2. t shifts one bit towards right and one bit is lost. %he result is '10' which is equivalent to
2. %he bit values will be same, 0 for positive number, 1 for negative number.
%he >>> is right shift unsigned operator. t shifts bits towards right. Zeros are fill in the left bits regardless of sign.
<<Previous Next>>
ExpIain with an exampIe how a cIass impIements an interface.
When a class implements an interface, it has to implement the methods defined inside that interface. %his is enforced
at build time by the compiler..........................
What is a task's priority and how is it used in scheduIing?
A task's priority is an integer value. %his value is used to identify the relative order of execution with respect to other
tasks..................

Wbat is an Anonynous inner class?
<<Previous Next>>
Java - What is an Anonynous inner class? Explain with an example - March 16, 2010 at 15:05 PM by Vidya
Sagar
hut lx un Anonynoux lnner cluxx? Fxpluln wlth un exumple
Anonymous Inner CIasses
An inner class without a name. t allows the declaration of the class, creation of the object and execution of the
methods in it at one shot. %he typical use of inner class is widely used in GU event handling.
For example
button.addActionListener(new ActionListener()
{
// %he way of using Anonymous nner class
public void actionPerformed(ActionEvent e)
{
System.out.println(%he button was pressed!);
}
});
n the above code snippet, there a definition of a new class while invoking another method. By utilizing an anonymous
inner class, the hard coding of defining a separate class and its methods and invoking them by creating an exclusive
object explicitly, is reduced to almost a single line within its containing class.
<<Previous Next>>
What is Bytecode?
%he Java class file contains bytecode which is being interpreted by JVM. Bytecode is introduced in Java to provide
Java as platform independent language.................
ExpIain how to force garbage coIIection
Garbage collection can't be forced, it can explicitly be called using System.gc(), but there is not guarantee that GC
will be started immediately.............

Wbat is co-variant return type in |ava?
<<Previous Next>>
Java - What is co-variant return type in java? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx co-vurlunt return type ln juvu?
A covariant return type allows to override a super class method that returns a type that sub class type of super class
method's return type. t is to minimize up casting and down casting.
%he following code snippet depicts the concept:
class Parent
{
Parent sampleMethod()
{
System.out.println("Parent sampleMethod() invoked);
return this;
}
}
class Child extends Parent
{
Child sampleMethod()
{
System.out.println("Child sampleMethod() invoked);
return this;
}
}
class Covariant
{
public static void main(String args[])
{
Child child1 = new Child();
Child child2 = new child1.sampleMethod();
Parent parent1 = child1.sampleMethod();
}
}.
<<Previous Next>>
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters.................
ExpIain the difference between StringBuiIder and StringBuffer cIass.
StringBuilder is unsynchronized whereas StringBuffer is synchronized. So when the application needs to be run only
in a single thread then it is better to use StringBuilder. StringBuilder is more efficient than StringBuffer............
efine collable collections in |ava
<<Previous Next>>
Java - Define collable collections in java. - March 16, 2010 at 15:05 PM by Vidya Sagar
eflne colluble collectlonx ln juvu.
A callable collection is an interface whose implementers define a single method with no arguments. %he Callable
interface resembles Runnable, as both are designed for the classes which potentially executed with another thread.
%he difference is Runnable cannot return value and throw an exception.
%he implementing classes have utility methods which convert from one common form to Callable classes.
<<Previous Next>>
What is the difference between a break statement and a continue statement?
A break statement when applied to a loop ends the statement. A continue statement ends the iteration of the current
loop and returns the control to the loop statement....................
Preemptive scheduIing vs. time sIicing.
Preemptive scheduling ensures the highest priority thread to execute until it enters the waiting or dead
states......................

Purpose of making a metbod tbread safe
<<Previous Next>>
Java - Purpose of making a method thread safe. How to make a method thread safe without using
synchronized keyword? - March 16, 2010 at 15:05 PM by Vidya Sagar
Purpoxe of muklng u methoJ threuJ xufe. ow to muke u methoJ threuJ xufe wlthout uxlng
xynchronlzeJ keyworJ?
Java supports threads natively without using additional libraries. Using 'synchronized' key word makes the methods
thread safe. %hread safe methods does not cause another thread to use the same CPU resources without any order,
thus ensures congestion. %hread safe ensures / guarantees the threads to use CPU resources one after another.
t is a very good programming standard to use thread safe collections like java.util.Hashtable, java.util.Vector, thread
safe class like StringBuffer . %heir methods are synchronized.
Single%hreadModel interface also supports making methods thread safe.
Certain collections can be made thread safe by using synchronizedSet(), synchronizedMap(), synchronizedList() and
synchronizedCollection() methods.
<<Previous Next>>
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
What is DatabaseMetaData?
DatabaseMetaData provides comprehensive information about the database. %his interface is implemented by the
driver vendors to allow the user to obtain information about the tables of a relational database as a part of JDBC
application...................
Wby a constructor doesnt bave return type?
<<Previous Next>>
Java - Can you explain why a constructor doesn't have return type? - March 16, 2010 at 15:05 PM by Vidya
Sagar
un you expluln why u conxtructor Joexnt huve return type?
%he primary goal of a constructor is to create an object. %hough the constructor resembles a method, its explicit
purpose is to initialize the instance variables. Assignment operation resembles like a method, it is to be done just
before an object is created. t is certain that the constructor can create the object of that class only. %his agreement is
unambiguous and crystal clear. Hence a constructor does not have return type.
<<Previous Next>>
ExpIain the Java CoIIection framework? What are the benefits of the Java coIIection framework?
A collection is a set of heterogeneous objects. A framework makes the applications efficient, less hard coded, similar
implementation for various.................
What is the purpose of the enabIeEvents() method?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event.................
What is the difference between a static and a non-static inner cIass?
Like static methods and static members are defined in a class, a class can also be static. %o specify the static class,
prefix the keyword 'static' before the keyword 'class'............


plain bow to add a button in applet
<<Previous Next>>
Java - Explain how to add a button in applet - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln how to uJJ u button ln upplet
%he following are the steps to add a button in applet:
1. Declare and create the object of Button class - Button clickMe;
2. n the method 'init()', create the object of the button - clickMe = new Button("Click Me);
3. Use the 'add()' method add(clickMe);
<<Previous Next>>
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
Latest answer: An event-listener interface allows describing the methods which must be implemented by one of the
event handler for a specific event..................
How can we handIe SQL exception in Java?
Latest answer: SQL Exception is associated with a failure of a SQL statement. %his exception can be handled like
an ordinary exception in a catch block..................


plain tbe purpose of |ar file
<<Previous Next>>
Java - Explain the purpose of jar file. Can you explain how to create a jar file in java - March 16, 2010 at 15:05
PM by Vidya Sagar
Fxpluln the purpoxe of jur flle. un you expluln how to creute u jur flle ln juvu
A Jar file contains mostly .class files and optionally other files like sound files, image files for Java applications,
gathered into a single file in the compressed format. %he JDK consists of all java class libraries are available as jar
files. n an enterprise a Java application can be started with a Jar file.
A jar file can be created from the command line / console window by using the 'jar' command.
For example, jar cvf inventory.jar *.class
n the above example, all the .class files are compressed and stored in the jar file 'inventory.jar'. Now, the
inventory.jar is a class library for inventory operations of an enterprise. %he 'c' stands for create, 'v' stands for
verbose, means to show details while creating the file and 'f' stands for the file followed by it.
<<Previous Next>>
What is the disadvantage of garbage coIIector?
Although garbage collector runs in its own thread, still it has impact on performance. t adds overheads since JVM
has to keep constant track of the object................
ExpIain cIass vs. instance with exampIe using java.
A class is a program construct which encapsulates data and operations on data. t is a blue print of an
object...................
)ava string
<<Previous Next>>
Java - Difference between String s="hello"; and String s=new String("hello"); in Java - March 16, 2010 at
15:05 PM by Vidya Sagar
lfference between Strlng x="hello", unJ Strlng x=new Strlng("hello"), ln juvu
%he statement String s = "hello is initialized to s and creates a single interned object. While String s = new
String("hello); creates two string objects, one interned object, two object on the heap.
<<Previous Next>>
What are transaction isoIation IeveIs in EJB?
%ransaction_read_uncommitted, %ransaction_read_committed, %ransaction_repeatable_read.................
What is the difference between doGet() and doPost()?
GE% Method: All data we are passing to Server will be displayed in URL. Here we have size limitation.............

)ava vs. )avascript
<<Previous Next>>
Java - Java vs. Javascript - March 16, 2010 at 15:05 PM by Vidya Sagar
juvu vx. juvuxcrlpt.
%he differences of Java and Java Script are:
- Java can stand on its own where as Java Script mandatorily be placed within an H%ML document.
- Java is larger and used to create stand alone applications. Where as Java Script is text which is fed into a browser
which can read it and later executed by the browser.
- Java must be compiled into machine language before it is presented to the end user. While Java Script does not
need a compiler or interpreter, it is executed through a web browser.
<<Previous Next>>
What's the difference between servIets and appIets?
Servlets executes on Servers while Applets executes on browser, Unlike applets, servlets have no graphical user
interface..................
What is a method? Provide severaI signatures of the methods.
A java method is a set of statements to perform a task. A method is placed in a class.Signatures of methods: %he
name of the method, return type and the number of parameters comprise the method signature...............

plain upcasting and downcasting in )ava.
<<Previous Next>>
Java - Explain upcasting and downcasting in Java. - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln upcuxtlng unJ Jowncuxtlng ln juvu.
Upcasting: Java permits an object of a sub class can be referred by its super class. t is done automatically.
Downcasting: t is to be performed manually by the developers. Here explicit casting is to be done by the super
class. For example:
Shape shape = new Shape() ;
Circle circ;
circ = (Circle) shape;
where shape is a super class object. Now the methods of Shape can be invoked by the reference variable circ.
<<Previous Next>>
What is the purpose of the enabIeEvents() method?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters.................
String objects are immutabIe in java. ExpIain how to create a string that can be changed.
A string object that is created using "String class is immutable. %he characters of the object can not be changed /
modified. %here are some methods, such as split(), substring(), beginsWith() etc................... .
Can you eplain benefits of classpatb?
<<Previous Next>>
Java - Can you explain benefits of classpath? - March 16, 2010 at 15:05 PM by Vidya Sagar
un you expluln benefltx of cluxxputh?
Classpath is the path in which JVM searches for class libraries at the time of compiling the Java Application. By
setting the CLASSPA%H environment variable, JVM invokes the Java AP and related classes, supported library files
needed for compiling java program. nstead of placing all the applications in the library directory, the applications can
be saved in different directories and set the classpath for compiling them.
<<Previous Next>>
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events.......................
What is ResuItSetMetaData?
ResultSetMetaData is an object that gets information about the types and properties of the columns in a ResultSet
object................
plain tbe reason of Uut of Memory eception in )ava.
<<Previous Next>>
Java - Explain the reason of Out of Memory exception in Java. - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln the reuxon of ut of Memory exceptlon ln juvu.
%he OutOfMemoryException can occur either the JVM may have a limit of memory to access to, or the system may
have run out of physical memory or the application might consume too much memory space. %o avoid these
situations to occur, the applications need to be rewritten or reconfigure the heap by increasing the size for JVM.
<<Previous Next>>
What is RefIection API in Java?
Reflection AP allows examining, modifying the run time behaviour of java applications running in the JVM...........
What is Map and SortedMap Interface?
A map is an object that maps the keys to values. Map provides the facility of storing elements without duplicate keys.
%he Map interface does not provide the sorted order of key and value pairs...............


Wbat will bappen wben esultSet is not closed?
<<Previous Next>>
Java - What will happen when ResultSet is not closed? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut wlll huppen when RexultSet lx not cloxeJ?
n a pooled database connection, it is returned to the pool and could close only after expiring its life time. n the mean
time many result sets might opened and left unclosed. f it happens on a single database by multiple applications, the
data updation is not perfect and may violate ACD properties rule for data presuming.
<<Previous Next>>
What is a task's priority and how is it used in scheduIing?
A task's priority is an integer value. %his value is used to identify the relative order of execution with respect to other
tasks..................
What is DatabaseMetaData?
DatabaseMetaData provides comprehensive information about the database. %his interface is implemented by the
driver vendors to allow the user to obtain information about the tables of a relational database as a part of JDBC
application..................
What is the difference between the iIe and RandomAccessiIe cIasses?
%he File class is used to perform the operations on files and directories of the file system of an operating system. %his
operating system is the platform for the java application that uses the File class objects.............
plain tbe use of Clonable,and serializable interface
<<Previous Next>>
Java - Explain the use of Clonable,and serializable interface. - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln the uxe of lonuble,unJ xerlullzuble lnterfuce.
%he similarity of Clonable and Serializable interfaces is that they both are marker interfaces.
Clonable: t is just an indicatory that a class is to use clone() method of the Object class to copy the instance of a
particular class.
Serializable: An object of a class is converted into byte stream and persisted in a local disk. t is useful to send the
objects in a network as a byte stream. Another network could convert the byte stream into Object of a particular class
type.
<<Previous Next>>
What is ResuItSetMetaData?
ResultSetMetaData is a class which provides information about a result set that is returned by an executeQuery()
method..................
Define cIass and object. ExpIain them with an exampIe using java.
Class: A class is a program construct which encapsulates data and operations on data. n object oriented
programming, the class can be viewed as a blue print of an object.....................
Wbat is ob|ect deep copy and sballow copy?
<<Previous Next>>
Java - What is object deep copy and shallow copy? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx object Jeep copy unJ xhullow copy?
n deep copy the copy operations would respect the semantics of the object. For example, copying an object along
with the objects to which it refers to.
A shallow copy copies an object without its contained objects.
<<Previous Next>>
String vs. StringBuffer cIass.
String class is immutable which means it can't be modified once declared.
StringBuffer is not immutable which means strings can be appended to the original string..............
ArrayIist vs. Vector
Arraylist's methods are not synchronized which means they are not thread safe. Vector's methods are synchronized
which means they are thread safe...............


Wbat is dynamic variable in |ava and wbere do we use tbem?
<<Previous Next>>
Java - What is dynamic variable in java and where do we use them? - March 16, 2010 at 15:05 PM by Vidya
Sagar
hut lx Jynumlc vurluble ln juvu unJ where Jo we uxe them?
%he variables that are initialized at run time is called as dynamic variable
<<Previous Next>>
ExpIain the methods that controI a AppIet's on-screen appearance, update and paint.
%o refresh a page in an applet window without flashing, the update() method is to be overridden. t clears the
background of the component, before invoking paint()..................
Concrete cIass vs. Abstract cIass vs. Interface.
A concrete class has concrete methods, i.e., with code and other functionality. %his class a may extend an abstract
class or implements an interface...................
What are different types of inner cIasses?
Local classes - Local classes are like local variables, specific to a block of code. %heir visibility is only within the block
of their declaration.............


plain tbe advantages of )TA over )TS
<<Previous Next>>
Java - Advantages of JTA over JTS - March 16, 2010 at 15:05 PM by Vidya Sagar
AJvuntugex of j1A over j1S
Java %ransaction AP is simple and more flexible to use. %here are two levels in J%A AP. %he lower operations are
taken by the server and the higher level operations are taken by the developers.
J%S is implemented by J%A. %he higher level operations are handled by J%A and the lower level operations are
handled by J%S.
<<Previous Next>>
What are the types of JDBC drivers?
Latest answer: JDBC-ODBC bridge plus ODBC driver, also called %ype 1, Native-AP, partly Java driver, also called
%ype 2................
What is cIass Ioader? ExpIain the purpose of Bootstrap cIass Ioader.
Latest answer: Class loader finds and loads the class at runtime. Java class loader can load classes from across
network or from other sources like H%%P, F%P etc................
Wbat is a resource leak?
<<Previous Next>>
Java - What is a resource leak? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx u rexource leuk?
Usually all operating systems have limitations for using the number of file handles, sockets etc., which can be open.
%he limit is quite low for certain resources. f the memory of the system is 128 KB, the Java program can easily
allocate all the resources available for handling files without filling up the heap. n this scenario, the Java program will
fail. %his situation is known as 'resource leak'. n other words, resource leak is an unintentional maintenance of
references to non-memory resources.
<<Previous Next>>
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
ExpIain the Java CoIIection framework? What are the benefits of the Java coIIection framework?
A collection is a set of heterogeneous objects. A framework makes the applications efficient, less hard coded, similar
implementation for various.................

Wbat is Bootstrap loader program?
<<Previous Next>>
Java - What is Bootstrap loader program? Explain its purpose - March 16, 2010 at 15:05 PM by Vidya Sagar
whut lx Bootxtrup louJer progrum? Fxpluln ltx purpoxe
Bootstrapping is a technique which activates more complex / complicated system of programs. When the system is
started, a program called Basic nput Output System, initializes and tests the available computer system resources
like peripherals, hardware, external memory devices are connected. Later it loads a program to allow the loading of
larger programs, such as operating systems. n real sense, the operating system is loaded by BOS boot strap
loader.
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
Latest answer: Preemptive scheduling enables the highest priority task execution until waiting or dead states
entered. t also executes, until a higher priority task enters..................
What is DatabaseMetaData?
Latest answer: DatabaseMetaData provides comprehensive information about the database. %his interface is
implemented by the driver vendors to allow the user to obtain information about the tables of a relational database as
a part of JDBC application..................
ExpIain the difference between StringBuiIder and StringBuffer cIass.
StringBuilder is unsynchronized whereas StringBuffer is synchronized. So when the application needs to be run only
in a single thread then it is better to use StringBuilder. StringBuilder is more efficient than StringBuffer............
Can you run tbe |ava program witbout main metbod?
<<Previous Next>>
Java - Can you run the java program without main method? - March 16, 2010 at 15:05 PM by Vidya Sagar
un you run the juvu progrum wlthout muln methoJ?
A java applet application, a web application can run without main method. A Java program can run without using '
public static void main(String args[]) ' method by using a static block.
%he static block gets executed soon after the class is loaded, even prior to the 'public static void main(String args[]) '.
JVM searches for main method only after exiting from the static block. JVM throws an exception if main method is not
found. %o avoid throwing this exception we can use System.exit(0);
%he following code depicts a class without main method; with only static block and System.exit(0).
class WithoutMainMethod {
static
{
System.out.println("%his class has no public static void main(String args[]) ");
System.out.exit(0);
}
}.
<<Previous Next>>
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters..................
What is the purpose of the enabIeEvents() method?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
Can you eplain wby servlets etend HttpServlet
<<Previous Next>>
Java - Can you explain why servlets extend HttpServlet - March 16, 2010 at 15:05 PM by Vidya Sagar
un you expluln why xervletx extenJ ttpServlet
Most of the web applications uses H%%Protocol. %he user requests need to be received and processed through the
H%%Protocol. Hence, the servlets should extend HttpServlet and override the doGet() and / or doPost() methods,
depending on the data that is sent by GE% or by POS%.
<<Previous Next>>
What is a Garbage coIIector?
Latest answer: Garbage collector cleans up objects which are no longer used. t is the thread running as part of JVM
process....................
What is package in JAVA?
Latest answer: Java packages help in organizing multiple modules. t helps in resolving naming conflicts when
different packages have classes with the same names............
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events........................


Wbat is Servlet Filter and bow does it work?
<<Previous Next>>
Java - What is Servlet Filter and how does it work? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx Servlet Fllter unJ how Joex lt work?
Filters are powerful tools in servlet environment. Filters add certain functionality to the servlets apart from processing
request and response paradigm of servlet processing. Filters manipulate the request and response in a web
application, and they can be applied to any resources like H%ML, graphics, a JSP page which are served by the
servlet engine. Authentication of data, format conversion of data and redirecting the page to another page are certain
useful functions of filters.
A filter is configured in a web.xml file. %he class using the filters should extend javax.servlet.Filter. Every request in a
web application, the servlet container decides the filters to apply and adds them to the filter chain, in the order they
appear in web.xml file. A filter also has life cycle mechanisms init(),doFilter() and destroy().
<<Previous Next>>
Test your )ava skills
Java part 1 (39 questions)
Java part 2 (40 questions)
EJB (20 questions)
JDBC (20 questions)
Applet (20 questions)
Struts (21 questions)
Servlets (20 questions)
Java web services (20 questions)
What is the difference between preemptive scheduIing and time sIicing?
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. t also
executes, until a higher priority task enters..................
What is DatabaseMetaData?
DatabaseMetaData provides comprehensive information about the database. %his interface is implemented by the
driver vendors to allow the user to obtain information about the tables of a relational database as a part of JDBC
application..................
What is Java IsoIates and why do we need it?
Java solates is an AP. t provides a mechanism to manage Java application life cycles which are isolated from each
other. %hey can potentially share the underlying implementation resources............ .
Use of logic:iterate tag in struts application
<<Previous Next>>
Java - Explain the use of <logic:iterate> tag in struts application - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln the uxe of <loglc:lterute> tug ln xtrutx uppllcutlon
%he tag is utilized for repeating the nested body content over a collection. Every element / object in a specified
collection which must be any one of terator, Collection and Map or even an array and their contents are nested
in this tag.
%he iterable collection must be specified in any one of the following methods:
- As a runtime expression that is specified as a value of the 'collection' attribute
- As a JSP bean that is specified by the 'name' attribute
- As the property that is specified by the 'property' of the JSP bean specified by the 'name' attribute.
Usually, every object that is exposed by the iterate tag is an object of the underlying collection that is to iterate over.
n case a Map is to iterate, the exposed object should be of the type Map.Entry, which has two properties i) key
the key under which the object / element is stored in a Map ii) value the value of corresponding key.
%he following example depicts the usage of Hashtable that is to iterate:
<logic:iterate id=account name=bankaccountnums>
Next account no is <bean:write name=account property=value/>
</logic:iterate>
<<Previous Next>>
ExpIain the difference between static and non-static member of a cIass.
A static field belongs to a class. %he objects of the class can not have the copy of these fields. %hese fields are
referred by the class name. Ex: Employee. company. Without creating an instance of a class, these fields can be
accessed....................
What's the difference between servIets and appIets?
Servlets executes on Servers while Applets executes on browser, Unlike applets, servlets have no graphical user
interface...................
ifference between atanputStream and Bufferedeader
<<Previous Next>>
Java - Difference between DataInputStream and BufferedReader - March 16, 2010 at 15:05 PM by Vidya Sagar
lfference between utuInputStreum unJ BuffereJReuJer
%he differences are:
%he DatanputStream works with the binary data, while the BufferedReader work with character data.
All primitive data types can be handled by using the corresponding methods in DatanputStream class, while only
string data can be read from BufferedReader class and they need to be parsed into the respective primitives.
DatanputStream is a part of filtered streams, while BufferedReader is not.
DatanputStream consumes less amount of memory space being it is binary stream, where as BufferedReader
consumes more memory space being it is character stream.
%he data to be handled is limited in DatanputStream, where as the number of characters to be handled has wide
scope in BufferedReader.
<<Previous Next>>
ExpIain the methods that controI a AppIet's on-screen appearance, update and paint.
%o refresh a page in an applet window without flashing, the update() method is to be overridden. t clears the
background of the component, before invoking paint()..................
ExpIain with an exampIe how a cIass impIements an interface.
When a class implements an interface, it has to implement the methods defined inside that interface. %his is enforced
at build time by the compiler..........................

ifference between tbrow and tbrows
<<Previous Next>>
Java - Difference between throw and throws - March 16, 2010 at 15:05 PM by Vidya Sagar
lfference between throw unJ throwx
%he throw key word is used to explicitly throw an exception, while throws is utilized to handle checked exceptions for
re-intimating the compiler that exceptions are being handled. t is kind of communicating to the compiler that an
exception is expected to throw one or more checked exceptions.
%he throws need to be used in the method's definition and also while invoking the method that raises checked
exceptions.
<<Previous Next>>
Advantages and disadvantages of interfaces.
nterfaces are mainly used to provide polymorphic behavior, nterfaces function to break up the complex designs and
clear the dependencies between objects.................
Difference between an Abstract cIass and Interface
An abstract class can have both abstract and concrete methods whereas an interface can have only method
signatures..................

Ways to serialize tbe |ava ob|ect
<<Previous Next>>
Java - Explain the ways to serialize the java object - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln the wuyx to xerlullze the juvu object
Object serialization could be used in different ways:
- Simple persistence of the object
- Reading from and writing to files
- RM technology for communicating across hosts.
%he encryption and decryption is left to the network transport. SSL or the like can be used when a secured channel is
needed.
<<Previous Next>>
What are access modifiers in JAVA?
Public %he member with public modifier can be access by any other class.
Protected %he member with protected modifier can be accessed by the derived class only..............
Difference between traditionaI java Array and ArrayIist cIass.
%raditional java array is fixed length whereas ArrayList supports dynamic arrays that can grow.................
Wbat are tbe similarities between an array and an ArrayList?
<<Previous Next>>
Java - What are the similarities between an array and an ArrayList? - March 16, 2010 at 15:05 PM by Vidya
Sagar
hut ure the xlmllurltlex between un urruy unJ un ArruyIlxt?
%he following are the similarities between an array and an ArrayList:
- Both array and ArrayList can have duplicate elements in them.
- Both are unordered lists.
- Both uses index to refer to their elements.
- Both supports null values
<<Previous Next>>
What is JNI?
Java Native nterface is a framework that allows the Java code running in the Java Virtual Machine to interact and
communicate with other applications and libraries written in some other languages................
What are inner cIasses?
Class that is nested within a class is called as inner class. %he inner class can access private members of the outer
class.................

Can we decide a session bean as stateless or stateful witbout seeing |ar file?
<<Previous Next>>
Java - Can we decide a session bean as stateless or stateful without seeing jar file? - March 16, 2010 at 15:05
PM by Vidya Sagar
un we JeclJe u xexxlon beun ux xtutelexx or xtuteful wlthout xeelng jur flle?
A bean can be determined whether is a stateless or stateful by analyzing the deployment descriptor ejb-jar.xml.
%he tags <session-type></session-type> provides the information. Stateless or Stateful words need to be placed
between begin and end tags.
For example:
<session-type>Stateless</session-type>
Or
<session-type>Stateful</session-type>
<<Previous Next>>
Where shouId we put appIet cIass fiIes, and how to indicate their Iocation using the AppIet tag?
An applet class file may present in any of the folder. %he .class file name along with its current path( in which this
.html file is placed) is to be specified in the code attribute of <Applet> tag.................
Java methods are virtuaI by defauIt. Comment.
Java methods are virtual by default. %he virtual methods are the methods of subclasses. %hey are invoked by a
reference of their super class...................
Wbat is non static block in |ava?
<<Previous Next>>
Java - What is non static block in java? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx non xtutlc block ln juvu?
Any code written between a { and a } is a non-static block.
for example:
{
// some code goes here
}
%he non-static block code is executed when a new class is instantiated. t executes before the constructor's
execution. Apart from initialization, any other execution like calculation could be given in the non-static block, as a
constructor is used for initializing purpose.
<<Previous Next>>
Difference between an abstract cIass and an interface and when shouId you use them
An abstract has one or more abstract methods apart from concrete methods. All the abstract methods must be
overridden by its subclasses..................
What is the purpose of the enabIeEvents() method?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................

plain bow to sort tbe elements in HasbMap
<<Previous Next>>
Java - Explain how to sort the elements in HashMap - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln how to xort the elementx ln uxhMup
%he elements of HashMap can be sorted by using the static method Collections.sort().
For example: Collections.sort(hashMapObject); // hashMapObject is an instance of HashMap.
<<Previous Next>>
What is singIeton cIass? Where is it used?
A class is defined as singleton class, if and only if it can create only one object. %his class is useful when only one
object is to be used in the application............
What is an AppIet?
An applet is a small server side application that can be loaded and controlled on the browser by the client
application...............
ifference between Cbecked and Uncbecked eception
<<Previous Next>>
Java - Difference between Checked and Unchecked exception - March 16, 2010 at 15:05 PM by Vidya Sagar
lfference between heckeJ unJ UncheckeJ exceptlon
A checked exception throws a block of code and represented by the throws keyword. t is utilized to handle invalid
criterions outside the control like invalid input, database issues, network outages, unavailable files.
An unchecked exception is utilized for representing defects in the program like invalid arguments passed to methods.
A checked exception need to be handled by try and catch blocks. A checked exception is a compile time exception.
Unchecked exception is a runtime exception.
<<Previous Next>>
What is LinkedList cIass?
LinkedList class implements the List interface. n addition to the List operations, the LinkedList class supports the
operations of inserting elements................
What are access modifiers in JAVA?
Public %he member with public modifier can be access by any other class.
Protected %he member with protected modifier can be accessed by the derived class only...............
Wby unnable interface is preferable tban etending tbe Tbread class
<<Previous Next>>
Java - Why Runnable interface is preferable than extending the Thread class - March 16, 2010 at 15:05 PM by
Vidya Sagar
hy Runnuble lnterfuce lx preferuble thun extenJlng the 1hreuJ cluxx
Runnable interface is always preferred because, the class implementing it can implement as many interfaces as a
developer can, and also extend another class. Whereas extending the %hread class, it can not extend another class,
as Java supports only single inheritance.
<<Previous Next>>
this vs. super keyword.
this refers to current object instance.
super refers to the member of superclass of the current object instance..................
Significance of inaIize method.
%he Finalize method of an object is called when GC is about to clean up the object. We can keep clean up code in
the finalize block..............
What is the advantage of the event-deIegation modeI over the earIier event inheritance modeI?
Event-delegation model allows a separation between a component's design and its use as it enables event handling
to be handled by objects other than the ones that generate the events........................
ifference between a |ava ob|ect reference and c++ pointer
<<Previous Next>>
Java - Difference between a java object reference and c++ pointer - March 16, 2010 at 15:05 PM by Vidya
Sagar
lfference between u juvu object reference unJ c polnter
%he prime difference is that pointers are to locate the address of the primitive variables only, where as object
reference locates the object in the heap.
<<Previous Next>>
What is the reIationship between an event-Iistener interface and an event-adapter cIass?
An event-listener interface allows describing the methods which must be implemented by one of the event handler for
a specific event..................
How are Observer and ObservabIe used?
All the objects which are the instances of the sub class Observable, maintains a list of observers...................


Wbat is )aspereports?
<<Previous Next>>
Java - What is JasperReports? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx juxperReportx?
Jasper Report is a very popular open source reporting tool written in Java. %he reports can be seen on the screen, on
a printer or into files like PDF,R%F,XML or also as H%ML,MS-Excel,CS%(comma-separated values) .
%he Jasper Reports are used in web-enabled applications including JEE, for generating dynamic content. %he reports
read the content from an XML file or .jasper file. %he data can be retrieved for various sources like JDBC, Java
Beans, EJBQL, XML, Hibernate and comma-separated values. Jasper Reports framework is plugging in a custom
JRQueryExecuter, which is an extension to Oracle PL/SQL stored procedures.
<<Previous Next>>
How are Observer and ObservabIe used?
%he observable class represents an observable object.
%he object to be observed can be represented by sub-classing observable class.................
What's the difference between servIets and appIets?
Servlets executes on Servers while Applets executes on browser, Unlike applets, servlets have no graphical user
interface..................

Spring framework vs. Struts framework
<<Previous Next>>
Java - Spring framework vs. Struts framework - March 16, 2010 at 15:05 PM by Vidya Sagar
Sprlng frumework vx. Strutx frumework
Struts:
Struts is a MVC pattern framework
Generating integration logic is done dynamically using Struts.
Struts support only JSP as a component view
Spring:
Spring supports other patterns along with MVC pattern
Spring supports views like Velocity, Freemaker etc., apart from JSP
Spring has 6 modules apart from existing JEE technologies.
<<Previous Next>>
Significance of inaIize method.
%he Finalize method of an object is called when GC is about to clean up the object. We can keep clean up code in
the finalize block...............
String vs. StringBuffer cIass.
String class is immutable which means it can't be modified once declared.
StringBuffer is not immutable which means strings can be appended to the original string...............
plain bow to convert |ava file to |ar files
<<Previous Next>>
Java - Explain how to convert java file to jar files - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln how to convert juvu flle to jur fllex
%he following is the process:
- %ype jar cvf <jarfilename.jar> <.java file(s)>
where c stands for create, v stands for verbose and f indicates the file follows it, into which the archive to be stored.
<.java file(s)> is the java files that are to be placed in the .jar file.
<<Previous Next>>
What is package in JAVA?
Java packages help in organizing multiple modules. t helps in resolving naming conflicts when different packages
have classes with the same names.............
Define cIass and object. ExpIain them with an exampIe using java.
Class: A class is a program construct which encapsulates data and operations on data. n object oriented
programming, the class can be viewed as a blue print of an object......................

escribe bow to use crystal reports in |ava.
<<Previous Next>>
Java - Describe how to use crystal reports in java - March 16, 2010 at 15:05 PM by Vidya Sagar
excrlbe how to uxe cryxtul reportx ln juvu.
nstall and run crystl32.cox file in \WNN%\System32 folder and specify the sub directory as 'crystal' as the output
directory.
- Create an object of CrystalReport class.
- nvoke aboutBox() method for confirmation whether it is loaded properly
- Establish the connection by using setConnect() method.
- Specify the output file format by using setReportFileName() method.
- Execute the query by using setSqlQuery() method.
- Set the number of copies of the report and the printer collation.
- Set the destination file using setDestination() method.
- Specify the file type using setPrintFile%ype () method.
- nvoke the method pritReport()
%he following is the code example:
public class CrystalReportExample
{
private static final String CONNEC%_S%RNG = DSN=ourDsn;
private static final String REPOR%_FLE_NAME = FileName.rpt;
private static final String SQL_QUER = select * from our%able;
private static final String PRN%_FLE = ourNewReport.doc;
public static void main(String args[]) throws Exception
{
try {
crystal.CrystalReport report = new crystal.CrystalReport();
report.aboutBox();
report.setConnect(CONNEC%_S%RNG); // database connection
report.setReportFileName(REPOR%_FLE_NAME); // name of the report file
report.setSQLQuery(SQL_QUER); // query to get the data from the table
report.setPrinterCopies((short) 1); // number of copies of the report
// specifying the printer collating sequence
report.setPrinterCollation(crystal.PrinterCollationConstants.crptDefault);
report.setDestination(crystal.DestinationConstants.crpt%oFile); // destination of the report
report.setPrintFileName(PRN%_FLE); // writing the report into the file
report.setPrintFile%ype(crystal.PrintFile%ypeConstants.crptWinWord); // the type of the report file
report.printReport(); // printing the report onto the destination with the specified requirements
}
finally
{
com.linar.jintegra.Cleaner.releaseAll(); // releasing all report resources.
}
}
}.
<<Previous Next>>
What is the difference between the iIe and RandomAccessiIe cIasses?
%he File class is used to perform the operations on files and directories of the file system of an operating system. %his
operating system is the platform for the java application that uses the File class objects..............
ExpIain how to create instance of a cIass by giving an exampIe.
Java supports 3 ways of creating instances - By using new operator Ex : Product prodMouse = new
Product();...............

plain wby |ava doesnt support multiple inberitance
<<Previous Next>>
Java - Explain why java doesn't support multiple inheritance - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln why juvu Joexnt xupport multlple lnherltunce
Java does not support multiple inheritances. %o avoid ambiguity problem Diamonds of Death and complexity of
multiple inheritance.
%he Diamond of Death is a problem without clarity. %he Diamond problem is:
%wo classes %wo and %hree inherit from class One. Class Four inherits from both %wo and %hree. When a method in
Four invokes a method that is defined in One, and %wo and %hree have overridden that method in different way, the
ambiguity and complexity occurs through which class does it inherits: class %wo or class %hree?
Like wise if it is encouraged to have more than two classes to inherit, the ambiguity raises which leads to future
conflict of applications.
<<Previous Next>>
What is the purpose of setAutoCommit do?
A connection is in auto-commit mode by default which means every SQL statement is treated as a transaction and
will be automatically committed after it is executed...................
What is cIass Ioader? ExpIain the purpose of Bootstrap cIass Ioader.
Class loader finds and loads the class at runtime. Java class loader can load classes from across network or from
other sources like H%%P, F%P etc.................
Wbat is tbe use of private constructor in )ava?
<<Previous Next>>
Java - What is the use of private constructor in Java? - March 16, 2010 at 15:05 PM by Vidya Sagar
hut lx the uxe of prlvute conxtructor ln juvu?
A private constructor is used when there is no requirement of another class to invoke that. t is used mostly in
implementing singletons. A static method is used for managing the creating the instances of that class.
%he following is the example of private constructor.
public class Singleton {
private static Singleton instance;.
//private constructor
private Singleton {
// some code goes here
}
}
<<Previous Next>>
What is the disadvantage of garbage coIIector?
Although garbage collector runs in its own thread, still it has impact on performance. t adds overheads since JVM
has to keep constant track of the object................
What is JDBC driver?
%he JDBC Driver provided by the JDBC AP, is a vendor-specific implementations of the abstract classes. %he driver
is used to connect to the database..............
plain bow to make a class immutable
<<Previous Next>>
Java - Explain how to make a class immutable - March 16, 2010 at 15:05 PM by Vidya Sagar
Fxpluln how to muke u cluxx lmmutuble
n order to make a class immutable, the changing state of the class object must be restricted. %his means restricting
an assignment to a variable. %his can be achieved by using 'final' access modifier. Make all methods in the class also
'final'. Even a better approach is to make the class itself as 'final' class. So that it can not be subclass-ed, and no
overriding occurs.
<<Previous Next>>
What is RefIection API in Java?
Reflection AP allows examining, modifying the run time behaviour of java applications running in the JVM...........
Advantages and disadvantages of interfaces.
nterfaces are mainly used to provide polymorphic behavior, nterfaces function to break up the complex designs and
clear the dependencies between objects.................

)ava metbods are virtual
Next question>>
Java methods are virtual - April 02, 2009 at 17:00 PM by Vidya Sagar
)ava metbods are virtual by default. Comment.
Java methods are virtual by default. %he virtual methods are the methods of subclasses. %hey are invoked by a
reference of their super class. %he methods of the object are invoked when a method is invoked by using the
reference to that object, hence they are virtual.
Java methods are virtual - July 31, 2009 at 14:00 PM by Amit Satpute
An approach followed by Java is to be able to override any method that one might need in the future. When a method
is declared virtual, a call back hook is created. %his greatly affects performance.
Next question>>


mplement an interface in )ava
Next question>>
Implement an interface in Java - April 02, 2009 at 17:00 PM by Vidya Sagar
plain witb an eample bow a class implements an interface.
First ,the interface is to be defined. Defining an interface is placing the method signatures.
%hen these methods are to be overridden in the class that implements the interface.
Ex:
interface QuestionAnswer {
String answerForQuestion(String qtn);
}
class AnswerForQuestion implements QuestionAnswer{
String answerForQuestion(String qtn) {
System.out.println("%he answer is " + qtn);
}
}
Create an object of the class AnswerForQuestion and invoke the answerForQuestion()
method.
AnswerForQuestion afq = newAnswerForQuestion();

Latest
pIacement tests
ASP.NE
%
C#.NE%
C++
Sql Server
Linux
Java
Oracle
Networking
Mysql
PHP
Data
Structure
More 100
tests....

Latest Iinks
How to
afq.answerForQuestion("Java is a programming language);
Implement an interface in Java - July 31, 2009 at 14:00 PM by Amit Satpute
When a class implements an interface, it has to implement the methods defined inside that
interface.
%his is enforced at build time by the compiler.
interface interfaceA
{
void methodA(int x);
}
class classA implements interfaceA
{
// implementation for methodA and the rest of the class code if any.
}
Next question>>
AIso read
ExpIain ShaIIow and deep cIoning.
Answer: Cloning of objects can be very useful if you use the prototype pattern or if you want
to store an internal copy......
What are static InitiaIizers?
Answer: A static initializer block resembles a method with no name, no arguments, and no
return type......
What is JAVAdoc utiIity?
Answer: Javadoc utility enables you to keep the code and the documentation in sync
easily......
Why do we need wrapper cIasses?
Answer: Wrapper classes are used to be able to use the primitive datatypes as objects........

write a good CV
15 common
job interview Q&A
8 things
NO% do in a GD
Cracking an
% interview
Promotions
and perks
E-mail
Etiquettes

Concrete class vs. Abstract class vs. nterface in )ava


Next question>>
Concrete class vs. Abstract class vs. Interface in Java - April 02, 2009 at 17:00 PM by Vidya Sagar
Concrete class vs. Abstract class vs. nterface.
A concrete class has concrete methods, i.e., with code and other functionality. %his class a may extend an abstract
class or implements an interface.
An abstract class must contain at least one abstract method with zero or more concrete methods
An interface must contain only method signatures and static members.
Concrete class vs. Abstract class vs. Interface in Java - July 31, 2009 at 14:00 PM by Amit Satpute
An interface does not have definitions of the methods declared in it.
An abstract class may have some definition and at least one abstract method.
A subclass of an abstract class must either implement all the abstract methods of the abstract class or declare itself
as abstract.
public abstract class A
{
public abstract void methodA();
public abstract void methodB();
}
class SubA extends A
{
void methodA()
{
// implementation
}
void methodB()
{
// implementation
}
}
interface interfaceA
{
void methodA(int x);
}
class classA implements interfaceA
{
// implementation for methodA and the rest of the class code if any.
}
Next question>>
AIso read
What is the purpose of Comparator Interface?
Answer: Comparators can be used to control the order of certain data structures and collection of objets too......
What is transient and voIatiIe modifiers?
Answer: When serializable interface is declared, the compiler knows that the object has to be handled..........
What is meant by getCodeBase and getDocumentBase method?
Answer: %he getCodebase() method is also commonly used to establish a path to other files............
How do I insert an image fiIe (or other raw data) into a database?
Answer - Upload all raw data-types (like binary documents) to the database as an array of.....
How can you retrieve data from the ResuItSet?
Answer - Create a result set containing all data from.....

esign a class to support cloning in )ava


Next question>>
Design a class to support cloning in Java - April 02, 2009 at 17:00 PM by Vidya Sagar
How do design a class so tbat it supports cloning?
-Define a class that implements Clonable interface.
- Override the clone() method of Object class. Some classes my need deep cloning and some shallow cloning.
Shallow cloning is most appropriate in the situation where a data element directly represents a value. Deep cloning
builds a new reference and a new object to refer to a new object.
Design a class to support cloning in Java - July 31, 2009 at 14:00 PM by Amit Satpute
%he Cloneable should be implemented.
clone( ) should be overridden in which super.clone( ) is called.
%he exceptions should be caught in super.clone() so that the overridden clone( )doesn't throw any exceptions.
Next question>>
AIso read
ExpIain the difference between static and dynamic cIass Ioading.
Answer: %he static class loading is done through the new operator......
What are static InitiaIizers?
Answer: A static initializer block resembles a method with no name, no arguments, and no return type......
ExpIain semaphore and monitors in java threading.
Answer: A semaphore is a flag variable used to check whether a resource is currently being used by another thread
or process.....
What is the difference between preemptive scheduIing and time sIicing?
Answer: Under time slicing, a task executes for a predefined slice of time and then reenters the pool of......
What is the advantage of using a PreparedStatement?
Answer - %here are two kinds of locking available in JDBC.....
What's the difference between TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE?
Answer - Constant indicating that the type for a ResultSet object is scrollable....
Synta for using tbe Applet tag
Next question>>
Syntax for using the Applet tag - April 02, 2009 at 17:00 PM by Vidya Sagar
plain tbe complete synta for using tbe Applet tag.
%he <Applet> tag has the following attributes:
Code: %o specify the .class
Width: %o indicate the width of the applet window at first time loading.
Height: %o indicate the height of the applet window at first time loading.
Example:
<Applet code=RegistrationForm.class width=400 height=400>
Welcome to the world of applets
</Applet>
Syntax for using the Applet tag - July 31, 2009 at 14:00 PM by Amit Satpute
<applet code=Applet123.class width=50 height=50>
</applet>
%he browser is informed to load the applet whose compiled code is in Applet123.class and to
set the size of the applet to 50x50 pixels.
Next question>>
AIso read
What is the purpose of Comparator Interface?
Answer: Comparators can be used to control the order of certain data structures and
collection of objets too......

Latest
pIacement tests
ASP.NE
%
C#.NE%
C++
Sql Server
Linux
Java
Oracle
Networking
Mysql
PHP
Data
Structure
More 100
tests....

Latest Iinks
How to
write a good CV
15 common
job interview Q&A
8 things
NO% do in a GD
Cracking an
% interview
Promotions
and perks
E-mail
What is JAVAdoc utiIity?
Answer: Javadoc utility enables you to keep the code and the documentation in sync
easily......
Why do we need wrapper cIasses?
Answer: Wrapper classes are used to be able to use the primitive datatypes as objects........
What is an abstract cIass? | ExpIain the difference between abstract cIass and
interfaces.
Answer: An abstract class defines an abstract concept which can't be.....
What are the different types of RowSet?
Answer - Connected: A connected RowSet Object is permanent in nature. t doesn't
terminate.....

Etiquettes

Applet class files & tbeir location


Next question>>
Applet class files & their location - April 02, 2009 at 17:00 PM by Vidya Sagar
Wbere sbould we put applet class files, and bow to indicate tbeir location using tbe Applet
tag?
An applet class file may present in any of the folder. %he .class file name along with its current path( in which this
.html file is placed) is to be specified in the code attribute of <Applet> tag. f the .class file is not in the current
directory,or in an url, the codebase attribute is used. %he codebase= attribute is used to specify a different directory.
Ex: <applet codebase=http://java.sun.com/applets/Nervous%ext/1.1 code=Nervous%ext.class width=400
height=75>
Applet class files & their location - July 31, 2009 at 14:00 PM by Amit Satpute
%he applet class files should be put in the same directory as the current H%ML document. %he following code
indicates how to set the location:
<applet codebase=http://careerride.com/Applet123 code=Applet123.class width=50 height=50>
</applet>
Next question>>
AIso read
ExpIain autoboxing and unboxing.
Answer: %o add any primitive to a collection, you need to explicitly box (or cast) it into an appropriate wrapper
class.....
What are daemon threads?
Answer: %hreads that work in the background to support the runtime environment are called daemon threads.....
ExpIain semaphore and monitors in java threading.
Answer: A semaphore is a flag variable used to check whether a resource is currently being used by another thread
or process.....
What is seriaIizabIe Interface?
Answer: f we want to transfer data over a network then it needs to be serialized. Objects cannot be
transferred........
What is an abstract cIass? | ExpIain the difference between abstract cIass and interfaces.
Answer: An abstract class defines an abstract concept which can't be.....
How do I insert an image fiIe (or other raw data) into a database?
Answer - Upload all raw data-types (like binary documents) to the database as an array of.....
Metbods to control applets appearance, update and paint
Next question>>
Methods to control applet's appearance, update and paint - April 02, 2009 at 17:00 PM by Vidya Sagar
plain tbe metbods tbat control a Applets on-screen appearance, update and paint.
%o refresh a page in an applet window without flashing, the update() method is to be overridden. t clears the
background of the component, before invoking paint().
paint(): Every applet must implement the paint() method. A Graphics object is passed to the paint() method.
drawstring() is the method used to write the contents on the applet's window. %he other methods of Graphics class
are setColor(),drawRect(),setBackground() etc. All these methods are to be implemented in the paint() method.
Methods to control applet's appearance, update and paint - July 31, 2009 at 14:00 PM by Amit Satpute
%he Applet class inherits a paint method from its parent Container class.
%he paint method is called when the applet is loaded, scrolled, etc.
%he update method is called in response to repaint and calls paint in turn.
Next question>>
How )ava interacts witb database
Next question>>
How Java interacts with database - April 02, 2009 at 17:00 PM by Vidya Sagar
plain bow )ava interacts witb database. ive an eample to eplain it.
Java interacts with database using an AP called Java Database Connectivity. JDBC is used to connect to the
database, regardless the name of the database management software. Hence , we can say the JDBC is a cross-
platform AP.
%he database is connected with a driver as long as the operations perform with a database manager.
Example:
Class.forName(DRVER).newnstance(); // registers the driver
Connection con = DriverManager.getConnection(jdbc:mysql://db_lhost:3306/,
contacts,username,password);//establishes the connection to the database manager
Statement stmt = con.createStatement();
ResultSet resSet = stmt.executeQuery("select * from emp);
%he above code snippet establishes the connection to the database manager and retrieve tuples.
How Java interacts with database - July 31, 2009 at 14:00 PM by Amit Satpute
Java uses the JDBC (Java Database Connectivity) which is a programming framework to let the communication
between the database and the programs.
try
{
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
Connection con=DriverManager.getConnection(jdbc:odbc:MyDSN,scott,tiger);
PreparedStatement stmt=con.prepareStatement(insert into Student%BL values(?,?,?));
stmt.setnt(1,13);
stmt.setString(2,Rob);
stmt.setnt(3,26);
int rows=stmt.executeUpdate();
System.out.println(rows+ rows inserted);
}
catch(ClassNotFoundException ce)
{
ce.printStack%race();
}
catch(SQLException se)
{
se.printStack%race();
}
Next question>>
AIso read
What are daemon threads?
Answer: %hreads that work in the background to support the runtime environment are called daemon threads.....
What are Checked and UnChecked Exception?
Answer: %he java.lang.%hrowable class has two subclasses Error and Exception. %here are two types.....
What is the difference between preemptive scheduIing and time sIicing?
Answer: Under time slicing, a task executes for a predefined slice of time and then reenters the pool of......
What is the difference between AWT and Swing?
Answer: Classes in swing are not OS dependent. %hey don't create peer components,..........
What JDBC objects generate SQLWarnings?
Answer - Connections, Statements and ResultSets generate SQLWarnings through getWarnings method......

SQL eception in )ava


Next question>>
SQL exception in Java - April 02, 2009 at 17:00 PM by Vidya Sagar
How can we bandle SQL eception in )ava?
SQL Exception is associated with a failure of a SQL statement. %his exception can be
handled like an ordinary exception in a catch block.
Ex: catch(SQLException sqle) {
// code to handle this exception
}
%he statement
mport java.sql.SQLException;
Should be given in the beginning of the corresponding .java file.
SQL exception in Java - July 31, 2009 at 14:00 PM by Amit Satpute
ow cun we hunJle SqI exceptlon ln juvu?
%he classes used to handle the SQL exceptions are:
ClassNotFoundException
SQLException
Next question>>
AIso read
What are Native methods in Java?
Answer: Java applications can call code written in C, C++, or assembler. %his is sometimes
done.........
What are static InitiaIizers?
Answer: A static initializer block resembles a method with no name, no arguments, and no
return type......
What is JAVAdoc utiIity?
Answer: Javadoc utility enables you to keep the code and the documentation in sync
easily......
What is the difference between error and an exception?
Answer: Errors are abnormal conditions that should never occur. Not to be confused with the

Latest
pIacement tests
ASP.NE
%
C#.NE%
C++
Sql Server
Linux
Java
Oracle
Networking
Mysql
PHP
Data
Structure
More 100
tests....

Latest Iinks
How to
write a good CV
15 common
job interview Q&A
8 things
NO% do in a GD
Cracking an
% interview
Promotions
and perks
E-mail
Etiquettes

compile time errors.....


What is the difference between AWT and Swing?
Answer: Classes in swing are not OS dependent. %hey don't create peer components,..........
.
What are the different types of RowSet?
Answer - Connected: A connected RowSet Object is permanent in nature. t doesn't
terminate.....

Wbat is atabaseMetaata?
Next question>>
What is DatabaseMetaData?- April 02, 2009 at 17:00 PM by Vidya Sagar
Wbat is atabaseMetaata?
DatabaseMetaData provides comprehensive information about the database. %his interface is implemented by the
driver vendors to allow the user to obtain information about the tables of a relational database as a part of JDBC
application. User can use this interface to deal with various underlying DBMSs. Some of the methods are:
getDatabaseMajorVersion(), getDatabaseMinorVersion(), getDatabaseProductName(),
getDatabaseProductVersion(), getMaxRowSize(), getPrimaryKeys(), getURL(), getUserName() etc.
What is DatabaseMetaData?- July 31, 2009 at 14:00 PM by Amit Satpute
public interface DatabaseMetaData
%his interface is implemented by driver vendors.
t lets users know the capabilities of a Database Management System (DBMS) in combination with the JDBC driver
that is used with it.
Next question>>
AIso read
ExpIain the impact of private constructor.
Answer: Private Constructors can't be access from any derived classes neither from another class......
What is the difference between preemptive scheduIing and time sIicing?
Answer: Under time slicing, a task executes for a predefined slice of time and then reenters the pool of......
What is an SQL Locator?
Answer - DBMS uses the logical pointers as identifiers to locate and manipulate the data......
What are the different types of RowSet?
Answer - Connected: A connected RowSet Object is permanent in nature. t doesn't terminate.....
What are the standard isoIation IeveIs defined by JDBC?
Answer - %he values are defined in the class java.sql.Connection and are: ......
Wbat is esultSetMetaata?
Next question>>
What is ResultSetMetaData? - April 02, 2009 at 17:00 PM by Vidya Sagar
Wbat is esultSetMetaata?
ResultSetMetaData is a class which provides information about a result set that is returned by an executeQuery()
method. JDBC details interrogation can be done by using ResultSetMetaData. t includes the information about the
names of the columns, number of columns, data type they contain etc. Some of the methods are:
getColumnClassName(), getColumnName(), getColumn%ype(), getColumn%ypeName(), getPrecision(),
get%ableName(), isReadOnly(), isWritable() etc.
Java - What is ResultSetMetaData? - with answers posted on July 22, 2008 at 17:10 pm
hut lx RexultSetMetuutu?
ResultSetMetaData nterface holds information about the columns in a ResultSet.
Java - What is ResultSetMetaData? - July 31, 2009 at 14:00 PM by Amit Satpute
ResultSetMetaData is an object that gets information about the types and properties of the columns in a ResultSet
object.
ResultSet resultSet1 = statement1.executeQuery(SELEC% a, b, c FROM %ABLE2);
ResultSetMetaData rsmd = rs.getMetaData();
Next question>>
AIso read
What are daemon threads?
Answer: %hreads that work in the background to support the runtime environment are called daemon threads.....
What are different types of inner cIasses?
Answer: Local classes - Local classes are like local variables, specific to a block of code.........
What is meant by getCodeBase and getDocumentBase method?
Answer: %he getCodebase() method is also commonly used to establish a path to other files............
What is an SQL Locator?
Answer - DBMS uses the logical pointers as identifiers to locate and manipulate the data......
What is optimistic concurrency controI?
Answer - n optimistic concurrency control, locks are granted without performing conflict checks......
Cacbeowset, )BCowset and Webowset
Next question>>
CacheRowset, JDBCRowset and WebRowset - April 02, 2009 at 17:00 PM by Vidya Sagar
plain Cacbeowset, )BCowset and Webowset.
A CacheRowSet object is a container for rows, that 'caches' the rows in the memory. %he operations on the rows can
be done without being connected to its data source. t is one of the Java bean components and is scrollable,
updatable and serializable. An object of CacheRow set contains results from a result set and data in the tabular form
such as a spread sheet. Modifications in the data, if any, in a CacheRowSet is permitted. %he updated data then can
be propagated back to the source of the data.
A JDBCRowSet is a connected row set. maintain the connection to a database with the help of JDBC drivers. t
effectively makes the driver as a Java Bean component. One more advantage of JDBCRowSet is that, it can make a
ResultSet object both scrollable and updatable. f a driver and a database do not support scrolling and updating of
result set, then an application can populate JDBCRowSet object along with data of a ResultSet object.
%o describe a RowSet object in XML format, the WebRowSet object is implemented. %he schema of WebRowSet
objects utilizes the specific SQL/XML schema annotations, which ensures greater platform inter-operability.
CacheRowset, JDBCRowset and WebRowset - July 31, 2009 at 14:00 PM by Amit Satpute
Fxpluln ucheRowxet, jBRowxet unJ ebRowxet.
JdbcRowSet is a connected type of rowset as it maintains a connection to the data source using a JDBC driver
CachedRowSet and WebRoeSet are disconnected types of rowsets as they are connected to the data source only
when reading data from it or writing data to it.
Example 1:
JdbcRowSet j = new JdbcRowSetmpl();
j.setCommand(SELEC% * FROM %ABLE_NAME);
j.setURL(jdbc:myDriver:myAttribute);
j.setUsername(XXX);
j.setPassword(o);
j.execute();
Example 2:
ResultSet rs = stmt.executeQuery(SELEC% * FROM AU%HORS);
CachedRowSet crset = new CachedRowSetmpl();
crset.populate(rs);
Example 3:
WebRowSet wrs = new WebRowSetmpl();
wrs.populate(rs);
wrs.absolute(2)
wrs.updateString(1, stringXXX);
Next question>>
AIso read
What are daemon threads?
Answer: %hreads that work in the background to support the runtime environment are called daemon threads.....
What causes the "No suitabIe driver" error?
Answer - Failure to load the appropriate JDBC driver before giving a call to .....
Advantages of JDBC.
Answer - Businesses can continue to use their installed databases and access.....
What are the different types of driver?
Answer - %ype 1......
What are the standard isoIation IeveIs defined by JDBC?
Answer - %he values are defined in the class java.sql.Connection and are: ......
ifferent types of locks in )BC
Next question>>
Different types of locks in JDBC - April 02, 2009 at 17:00 PM by Vidya Sagar
Wbat are tbe different types of locks in )BC? plain tbem
A lock is a preventive software mechanism that other users can not use the data resource.
%he types of locks in JDBC:
Row and Key Locks:
Useful when updating the rows (update, insert or delete operations), as they increase
concurrency.
Page Locks:
Locks the page when the transaction updates or inserts or deletes rows or keys. %he
database server locks the entire page that contains the row. %he lock is made only once by
database server, even more rows are updated. %his lock is suggested in the situation where
large number of rows is to be changed at once.
%able Locks:
Utilizing table locks is efficient when a query accesses most of the tables of a table. %hese are
of two types:
a) Shared lock:
One shared lock is placed by the database server, which prevents other to perform any
update operations.
b) Exclusive lock:
One exclusive lock is placed by the database server, irrespective of the number of the rows
that are updated.
Database Lock:
n order to prevent the read or update access from other transactions when the database is
open, the database lock is used.
Next question>>
AIso read
What is RefIection API in Java?
Answer: %he Reflection AP allows Java code to examine classes and objects at run time.....
What is the purpose of Comparator Interface?
Answer: Comparators can be used to control the order of certain data structures and

Latest
pIacement tests
ASP.NE
%
C#.NE%
C++
Sql Server
Linux
Java
Oracle
Networking
Mysql
PHP
Data
Structure
More 100
tests....

Latest Iinks
How to
write a good CV
15 common
job interview Q&A
8 things
NO% do in a GD
Cracking an
% interview
Promotions
and perks
E-mail
Etiquettes

collection of objets too......


What is Map and SortedMap interface?
Answer: Maps are used to store the key-Value pairs.....
ExpIain the difference between StringBuiIder and StringBuffer cIass.
Answer: StringBuilder is unsynchronized whereas StringBuffer is synchronized.....
ExpIain how to impIement poIymorphism in JAVA.
Answer: Capacity of a method to do different things based on the object that......




What is ORM?
Latest answer: Object Relational Model is a programming technique. %his technique is used to convert the data from
an incompatible type to that of a relational database. %he mapping is done by using the OOP..............
Read answer
What is Hibernate?
Latest answer: Hibernate is an ORM tool. Hibernate is a solution for object-relational mapping and a persistence
management layer. For example a java application is used to save data of an object to a database.................
Read answer
Why do you need ORM tooIs Iike hibernate?
Latest answer: Hibernate is open source ORM tool. Hibernate reduces the time to perform database operations.
Hibernate has advantages over using entity beans or JDBC calls. %he implementation is done by just using
POJOs............
Read answer
What are the main advantages of ORM Iike hibernate?
Latest answer: %he SQL code / statements in the application can be eliminated without writing complex JDBC /
Entity Bean code.................
Read answer
What are the core interfaces of Hibernate framework?
Latest answer: Session Interface: %he basic interface for all hibernate applications. %he instances are light
weighted and can be created and destroyed without expensive process............
Read answer
ExpIain how to configure Hibernate.
Latest answer: Hibernate uses a file by name hibernate.cfg.xml. %his file creates the connection pool and
establishes the required environment. A file named .hbm.xml is used to author mappings...............
Read answer
Define HibernateTempIate.
Latest answer: Hibernate%emplate is a helper class that is used to simplify the data access code. %his class
supports automatically converts HibernateExceptions which is a checked exception into..............
Read answer
What are the benefits of HibernateTempIate?
Latest answer: Hibernate%emplate, which is a Spring %emplate class, can simplify the interactions with Hibernate
Sessions............
Read answer
What is Hibernate proxy?
Latest answer: Mapping of classes can be made into a proxy instead of a table. A proxy is returned when actually a
load is called on a session...........
Read answer
ExpIain the types of Hibernate instance states.
Latest answer: %he persistent class's instance can be in any one of the three different states. %hese states are
defined with a persistence context. %he Hibernate has the following instance states:.............
Read answer
ExpIain the CoIIection types in Hibernate.
Latest answer: A collection is defined as a one-to-many reference. %he simplest collection type in Hibernate
is...........
Read answer
What is Iazy initiaIization in hibernate?
Latest answer: %he delaying the object creation or calculating a value or some process until the first time it is
needed. %he retrieval of particular information only at the time when the object is accessed............
Read answer
What is Iazy fetching in hibernate?
Latest answer: Lazy fetching is associated with child objects loading for its parents. While loading the parent, the
selection of loading a child object is to be specified / mentioned in the hbm.xml file..............
Read answer
What is the difference between sorted and ordered coIIection in hibernate?
Latest answer:
Sorted CoIIection
%he sorted collection is a collection that is sorted using the Java collections framework. %he sorting is done in the
memory of JVM that is running hibernate, soon after reading the data from the database............
Read answer
ExpIain the difference between transient (i.e. newIy instantiated) and detached objects in hibernate.
Latest answer: %ransient objects do not have association with the databases and session objects. %hey are simple
objects and not persisted to the database...........
Read answer
ExpIain the advantages and disadvantages of detached objects.
Latest answer: Detached objects passing can be done across layers upto the presentation layer without using Data
%ransfer Objects................
Read answer
What is Hibernate Query Language (HQL)?
Latest answer: Hibernate Query Language is designed for data management using Hibernate technology. t is
completely object oriented and hence has notions like inheritance, polymorphism and abstraction............
Read answer
ExpIain the generaI fIow of Hibernate communication with RDBMS?
Latest answer: %he Hibernate configuration is to be loaded and creation of configuration object is done. %he
mapping of all hbm files will be performed automatically............
Read answer
ExpIain the roIe of Session interface in Hibernate.
Latest answer: Session interface is a single threaded object. %he representation of single unit of work with the Java
application and the persistence database is done by this object..........
Read answer
What is a Sessionactory?
Latest answer: %he SessionFactory is the concept that is a single data store and thread safe. Because of this
feature, many threads can access this concurrently and the sessions are requested, and also.............
Read answer
State the roIe of Sessionactory interface pIays in Hibernate.
Latest answer: %he SessionFactory is used to create Sessions. Each application is having usually only one
SessionFactory...........
Read answer
ExpIain the difference between Ioad() and get() in Hibernate.
Latest answer: Ioad()
Use this method if it is sure that the objects exist.
%he load() method throws an exception,when the unique id could not found in the database..................
Read answer
What is the difference between merge and update?
Latest answer: update () : When the session does not contain an persistent instance with the same identifier, and if it
is sure use update for the data persistence in hibernate..........
Read answer
What is the advantage of Hibernate over jdbc?
Latest answer: Hibernate code will work well for all databases, for ex: Oracle,MySQL, etc. where as JDBC is
database specific...........
Read answer
Why hibernate is advantageous over Entity Beans & JDBC?
Latest answer: An entity bean always works under the EJB container, which allows reusing of the object external to
the container. An object can not be detached in entity beans and in hibernate detached objects are
supported..............
Read answer
ExpIain the main difference between Entity Beans and Hibernate.
Latest answer: Entity beans are to be implemented by containers, classes, descriptors. Hibernate is just a tool that
quickly persist the object tree to a class hierarchy in a database and without using a single SQL..................
Read answer
ExpIain the difference between hibernate and Spring.
Latest answer: Hibernate is an ORM tool for data persistency. Spring is a framework for enterprise
applications...............
What is Java Authentication and Authorization Service, JAAS?
Latest answer: JAAS is an AP used for identifying a user or computer that is attempting to execute Java code and
ensures that, the right of executing functions requested............
Read answer
eatures of JAAS.
Latest answer: %he features of JAAS are:
A Pluggable Authentication Module framework of Java................
Read answer
JAAS infrastructure has two services: authentication and authorization. ExpIain the two services.
Latest answer: JAAS authentication component reliably and securely determines who is currently processing Java
code. %he code could be running an application, an applet, a bean or even a servlet / JSP..............
Read answer
JAAS authentication from your appIication typicaIIy invoIves the steps. ExpIain the steps
Latest answer: %he steps that are involved in JAAS authentication are:
Creation of LoginContext.............
Read answer
Describe authorization with JAAS.
Latest answer: JAAS authorization is an extension of Java security architecture, used to specify what the accessible
rights are granted to the existing code...............
Read answer
ExpIain the Authentication iIes
Latest answer: SimpleAuth.java %his file has main() method. %he main() method creates a LoginContext object. A
LoginModule configuration id and an instance of the CallbackHandler interface are passed while creating a
LoginContext object. By looking for the configuration d, the LoginContext reads a configuration file............
Read answer
ExpIain the Authorization iIes.
Latest answer: SimpleAuthz.java %his class is similar to the SimpleAuth.java class with one difference. A
privileged action is performed after authenticating the user. %o perform the privileged action, a reference to the
current Subject..........
Read answer
What are JAAS permissions?
Latest answer: Permissions are the core part of authorization. Access to resources is controlled by permissions.
JAAS permissions are built on top of Java security model............
Read answer
Overview of the Login Process in JAAS
Latest answer: %he login process starts when an access request to an application that is running on Java
Authentication System. For example, when a web application is accessed by a web client, the web container which
runs the..................
Discuss about JavaMaiI.
Latest answer: Java Mail is an AP that is used to receive and send emails between applications. %o send the
emails, the protocols, SMP%, POP AND MAP are used. %he messages sending and receiving is done by creating a
framework using set of abstract classes in the AP.................
Read answer
ExpIain POP, SMTP and IMAP protocoIs.
Latest answer: POP: %he Post Office Protocol is an application-level protocol within an intranet which are used by
the local e-mail clients to send and retrieve e-mails from a remote server those are connected using %CP/P. POP is
one of the most prevalent protocol fro the usage of e-mail..
Read answer
ExpIain the use of MIME within message makeup.
Latest answer: MME message includes the picture stored as file in GF format and the GF format uses 8-bit format.
%he RFC 822 uses ASC text format. %he messages in the form of ASC text format is to be encoded...............
Read answer
ExpIain the structure of JavamaiI API
Latest answer: %he JavaMail AP has classes such as Message, Store and %ransport. %he AP can be used to
subclass for providing new protocols and some additional functionality when needed................

What is Tomcat?
Latest answer: %omcat is a Java Servlet container and web server from Jakartha project of Apache software
foundation. A web server sends web pages as response to the requests sent by the browser client...............
Read answer
What is Jasper?
Latest answer: Jasper is a program to read the .class files in binary format. %his program can generate ASC files ,
which can be used along with Jasmin Assembler.................
Read answer
ExpIain the concepts of Tomcat ServIet Container.
Latest answer: %omcat Servlet Container is a servlet container. %he servlets runs in servlet container.
%he implementation of Java Servlet and the Java Server Pages is performed by this container.............
MIDP overview
Latest answer: A profile is defined as a supporting device. %he Mobile nformation Device Profile defines a set of
classes for the user of cellular phones. %he MDP is based on the CLDC JVM...........
Read answer
ExpIain the hardware requirement of MIDP.
Latest answer: %he MDP is intended for small devices with limited memory, CPU and display capabilities.
%he hardware requirements for MDP are:
Memory: At least 128 KB of RAM for installation of MDP. %here must be at least 32KB for java heap. At least 8KB of
non-volatile memory is required....................
Read answer
What is MIDLETS?
Latest answer: MDLE% is an application written for MDP. t is a java program for embedded devices, specifically for
JVM for JME.................
Read answer
Discuss about MIDLET security.
Latest answer: All the MDlet suites are restricted to operate within a security model. %his process is to prevent the
access to sensitive APs and functions of devices and avoiding risks to the device resources is primarily done by the
MDlets..................
Read answer
ExpIain the IifecycIe of a MIDLET.
Latest answer: %he MDlet lifecycle is the fundamental for creation of any MDlet. %he lifecycle includes the
execution states such as creation, start, pause and exiting operations and a set of valid transitions...............
Weblogic interview questions
Weblogic %est (15 questions)
ExpIain the concepts and capabiIities of Web Logic Server.
Latest answer: Web Logic server supports the services and infrastructure for JEE applications. %he deployment of
java applications and components as services through SOAP, UDD and WSDL, is performed by Web Logic
server................
Read answer
What is the function of T3 in WebLogic Server?
Latest answer: %he enhancements support for WebLogic Server messages is provided by %3. %hese enhancements
include object replacement, which work in WebLogic Server clusters' context and H%%P...............
Read answer
How do stubs work in a WebLogic Server cIuster?
Latest answer: %he enhancements support for WebLogic Server messages is provided by %3. %hese enhancements
include object replacement, which work in WebLogic Server clusters' context and H%%P.................
Read answer
What happens when a faiIure occurs and the stub cannot connect to a WebLogic Server instance?
Latest answer: %he stub removes the instance that is failed from its list, when a failure occurs. %he stub uses DNS
again for the purpose of finding a running server and obtains a current list of instances.................
Read answer
How do cIients handIe DNS requests to faiIed servers?
Latest answer: %he bandwidth will be wasted if the DNS continually sends requests to the unavailable machine,
when the server is failed so. %his problem occurs only during start up, for a client application..............
Read answer
ExpIain how to create PooIing in tomcat?
Latest answer: %he following are the steps to create Pooling in tomcat:............
Read answer
What is the difference between webIogic and websphere?
Latest answer: %hough the functionality of these two products are closer, there are minor differences in the
standards that support. %hese differences are:...............
Ant interview questions
ExpIain the concepts and capabiIities of ANT.
Latest answer: Capabilities of AN%: AN% tool is extended by using java classes. %he configuration files are XML-
based. Each task of building directory tree is executed by using the object that implements the %ask interface.............
Read answer
ExpIain how to start to use Ant and provide a "HeIIo WorId" ant script.
Latest answer: Before start using ant, we should be clear about the project name and the .java files and most
importantly, the path where the .class files are to be placed...............
Read answer
ExpIain how to set cIasspath in ant.
Latest answer: %he following is the code snippet to set the classpath in ant:
<path id=build.classpath>
<fileset dir=${build.lib} includes=**/*.jar/>
<fileset dir=${build.class}/>
</path>.................
Read answer
How does ant read properties? How to set my property system?
Latest answer: Properties in ant are set in an order. Once a property is set, later the same property can not
overwrite the previous one. %his process provides a good leverage of presetting all properties in one location, and
overwriting only the needed properties.................
Read answer
ExpIain how to modify properties in ant.
Latest answer: We can not modify the properties in ant. %he properties in ant are immutable in nature.................
Read answer
ExpIain how to use Runtime in ant.
Latest answer: %here is no need to use Runtime in ant. Because ant has Runtime counterpart by name Exec%ask.
Exec%ask is in the package org.apache.tools.ant.taskdefs..............
Read answer
How can I use ant to run a Java appIication?
Latest answer: %he following is an example to run a java application in using ant:
<target name=run depends=some.target,some.other.target>
<java classname=${run.class} fork=yes>
<classpath>.....................
Read answer
ExpIain how to debug my ant script.
Latest answer: Ant script can be debugged in the following ways: By echoing at the place to debug. %he problem is
easily known. %his is similar to printf () function in C and System.out.println() in Java............
Read answer
How can I write my own ant task?
Latest answer: Define the user defined custom script and use taskdef to define in the custom script..............
Read answer
ExpIain how to use ant-contrib tasks.
Latest answer: 1. Copy the ant-contrib.jar to the directory ant*/lib. Copy ant-contrib.jar to your ant*/lib directory.
2. Append the following code snippet to avail all the ant-contrib tasks...............
Read answer
ExpIain how to make ant user interactive.
Latest answer: %he org.apache.tools.ant.input.nputHandler interface is used to implement the user input. %o
perform the user input, the application creates nputRequest object and this object will be passed to
nputHandler..................
Webspbere interview questions
Websphere %est (15 questions)
What is WebSphere?
Latest answer: WebSphere refers to a brand for BM software products. t is designed for setting up, operation and
integration of electronic business applications.............
Read answer
What is WebSphere Commerce?
Latest answer: WebSphere Commerce is a software platform framework from BM. %his framework provides the
functionality for e-commerce, including sales, marketing, customer support and order processing
functionality..............
Read answer
ExpIain the architecture of WebSphere.
Latest answer: WebSphere architecture consists of one or more computer systems which are called nodes. Nodes
are available within WebSphere cell. A WebSphere cell can have one node.................
Read answer
State some of the features present in websphere.
Latest answer: Suports the Servlet/JSP container functionality which runs on top of H%%P, Supports H%%P servers
such as BM H%%P server, MS S and Netscape iPlanet server...............
Read answer
What is IBM WebSphere edge server?
Latest answer: WebSphere Edge Server allows deploying parts of an application that contains servlets or JSP
components to a proxy cache and executes at the cache...............
Read answer
What is extended deployment in WebSphere?
Latest answer: WebSphere Extended Deployment is a new product for BM WebSphere software. WED extends the
WebSphere software platform..............
Read answer
What is asymmetric cIustering in WebSphere?
Latest answer: n asymmetric clustering, the partitions can be declared dynamically and usually run on a single
cluster at a time.................
Read answer
What is Web sphere MQ JMS Provider?
Latest answer: %he usage of WebSphere MQ is employed to use as Java Message Service provider for JEE
applications which are deployed in WebSphere Application Server................
Read answer
ExpIain the attribute CHANNEL in websphere MQ.
Latest answer: A channel is a connection that is to establish a link between sending channel and receiving channel.
A channel has a sender channel at the local queue manager and receiver channel at the remote queue
manager..............
Read answer
ExpIain about websphere MQ ReaI time transport.
Latest answer: t is a lightweight protocol. %his protocol is optimized for use with messages that are non-persistent.
WebSphere MQ Real %ime %ransport is utilized only by JMS clients...............
uby interview questions
Overview of Ruby programming Ianguage.
An open source programming language that focuses on simplicity and productivity. %he syntax of Ruby language is
elegant which is natural to read and easy to write. Ruby is well known as language of careful balance. t has the
blended features of Perl, Small talk, Eiffel, Ada and Lisp................
What is RaiIs?
Ruby on Rails is an open source web application framework for the Ruby programming language............
Describe cIass Iibraries in Ruby.
%he Ruby standard library extends the foundation of the Ruby built-in library with classes and abstractions for a
variety of programming needs, including network programming, operating system services, threads, and more............
ExpIain the concepts and capabiIities of garbage coIIection feature of Ruby.
Ruby is an object oriented language and every object oriented language tends to allocate many objects during
execution of the program.............
Describe the environment variabIes present in Ruby.
RUBOP%, RUBLB, RUBPA%H, RUBSHELL,RUBLB_PREFX...................
InterpoIation is a very important process in Ruby, comment.
nterpolation is the process of inserting a string into a literal..............
What is the use of super in Ruby RaiIs?
Ruby uses the super keyword to call the superclass implementation of the current method.............
What is the use of Ioad and require in ruby?
Reuire() loads and processes the Ruby code from a separate file, including whatever classes, modules, methods,
and constants are in that file into the current scope..............
ExpIain the use of gIobaI variabIe $ in Ruby.
f you declare one variable as global we can access any where, where as class variable.............
ExpIain the difference between niI and faIse in ruby.
False is a boolean datatype
Nil is not a data type..............
)ava design patterns interview questions
What is a software design pattern?
Latest answer: A reusable software design solution in general for the problems that are recurrently occuring. Design
pattern is not a solution but a description for how to solve a problem in different situations.............
Read answer
What is an anaIysis pattern?
Latest answer: t is a software pattern which is not related to a language. t is related to a business domain like
health care, telecom..............
Read answer
What are the differences between anaIysis patterns and design patterns?
Latest answer: Analysis pattern are targeted for domain architecture, where as design pattern are targeted for
implementation mechanism for some of the aspects of the domain...............
Read answer
What is SingIeton pattern?
Latest answer: Singleton pattern is one of the design patterns that is utilized for restricting instantiation of a class to
one or few specific objects................
Read answer
How do you write a Thread-Safe SingIeton?
Latest answer: %he following are the steps to write a thread-safe singleton: Declare a Boolean variable,
'instantiated', to know the status of instantiation of a class, an object of Object class and a variable of the same class
with initial value as null..............
Read answer
What is the Reactor pattern?
Latest answer: %he Reactor pattern is an architectural pattern that allows demultiplexing of event-driven applications
and dispatch service requests which are delivered by one or more application clients to an application.............
Read answer
What are Process Patterns?
Latest answer: Methods, best practices, techniques for developing an Object-Oriented software comprises a
process pattern................
Read answer
What are CoIIaboration Patterns?
Latest answer: Repeatable techniques which are utilized by people of different teams for helping them work
together. %he really have nothing to do with object-oriented development.................
Read answer
What is session facade?
Latest answer: Session Faade is one of the design pattern. t is utilized in developing enterprise applications
frequently..................
Read answer
What are Anti-Patterns?
Latest answer: A design pattern which obviously appears, but is an ineffective or far from optimal in practice. %here
must be atleast two key elements...............
Read answer
How do I document a design pattern?
Latest answer: %he following are the major points for describing a pattern. Short and meaningful name for the
pattern is to be selected. Problem description and goals and constraints that may occur in that context is to be
identified....................
Read answer

Anda mungkin juga menyukai