0% found this document useful (0 votes)
88 views27 pages

Good Questions

The following questions are unrelated with java technology, but they may be asked. Handle it by minimizing your weakness and emphasizing your strengths. Don't be critical, focus on what you can do try to be humor to show your smartness.

Uploaded by

api-3836483
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views27 pages

Good Questions

The following questions are unrelated with java technology, but they may be asked. Handle it by minimizing your weakness and emphasizing your strengths. Don't be critical, focus on what you can do try to be humor to show your smartness.

Uploaded by

api-3836483
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 27

90% interviewing questions raised based on your own resume.

eye-to-eye contact, smiling all the way. don't miss anyone in the corner.
asking easier and relevant questions back to the interviewers occasionally.
be honest to answer technical questions, you are not expert to know everything.
don't let your boss feel you might be a threat to take his position.
don't be critical, focus on what you can do
try to be humor to show your smartness.
don't act in a superior way.
find right time to raise questions and answer those questions to show your
strength.
aggressively to get candidacy info back after interviewing.

--------------------------------------------------------------------------------

the following questions are unrelated with java technology, but they may be asked.
so study this list, plan your answers ahead of time and you'll be ready to deliver
them with confidence. (cited from my email box someone sent)

what are your weaknesses?


this is the most dreaded question of all. handle it by minimizing your weakness
and emphasizing your strengths. stay away from personal qualities and concentrate
on professional traits: "i am always working on improving my communication skills
to be a more effective presenter. i recently joined toastmasters.com, which i find
very helpful."

--------------------------------------------------------------------------------

why should we hire you?


summarize your experiences: "with five years' experience working in this industry
and my proven record of saving the company money, i could make a big difference in
your company. i'm confident i would be a great addition to your team."

--------------------------------------------------------------------------------

why do you want to work here?


the interviewer is listening for an answer that indicates you've given this some
thought and are not sending out resumes just because there is an opening. for
example, "i've selected key companies whose mission statements are in line with my
values, where i know i could be excited about what the company does, and this
company is very high on my list of desirable choices."

--------------------------------------------------------------------------------

what are your goals?


sometimes it's best to talk about short-term and intermediate goals rather than
locking yourself into the distant future. for example, "my immediate goal is to
get a job in a growth-oriented company. my long-term goal will depend on where the
company goes. i hope to eventually grow into a position of responsibility."

--------------------------------------------------------------------------------

why did you leave (are you leaving) your job?


if you're unemployed, state your reason for leaving in a positive context: "i
managed to survive two rounds of corporate downsizing, but the third round was a
20 percent reduction in the workforce, which included me."

if you are employed, focus on what you want in your next job: "after two years, i
made the decision to look for a company that is team-focused, where i can add my
experience."

--------------------------------------------------------------------------------

when were you most satisfied in your job?


the interviewer wants to know what motivates you. if you can relate an example of
a job or project when you were excited, the interviewer will get an idea of your
preferences. "i was very satisfied in my last job, because i worked directly with
the customers and their problems; that is an important part of the job for me."

--------------------------------------------------------------------------------

what can you do for us that other candidates can't?


what makes you unique?
this will take an assessment of your experiences, skills and traits. summarize
concisely: "i have a unique combination of strong technical skills, and the
ability to build strong customer relationships. this allows me to use my knowledge
and break down information to be more user-friendly."

--------------------------------------------------------------------------------

what are three positive things your last boss would say about you?
it's time to pull out your old performance appraisals and boss's quotes. this is a
great way to brag about yourself through someone else's words: "my boss has told
me that i am the best designer he has ever had. he knows he can rely on me, and he
likes my sense of humor."

--------------------------------------------------------------------------------

what salary are you seeking?


it is to your advantage if the employer tells you the range first. prepare by
knowing the going rate in your area, and your bottom line or walk-away point. one
possible answer would be: "i am sure when the time comes, we can agree on a
reasonable amount. in what range do you typically pay someone with my background?"

--------------------------------------------------------------------------------

if you were an animal, which one would you want to be?


interviewers use this type of psychological question to see if you can think
quickly. if you answer "a bunny," you will make a soft, passive impression. if you
answer "a lion," you will be seen as aggressive. what type of personality would it
take to get the job done? what impression do you want to make?

--------------------------------------------------------------------------------

why do you like to join us?


be honest to answer such question. sample answer would be: because i like your
company, etc. and i am capable of doing a good job. or i just move to this area
and i am looking for the job that suits me very well...

--------------------------------------------------------------------------------

how did you handle your most challenging experience in your previous job?
smoothly, generally speaking. but i am a good team work player and always share my
experience with others and learn from others.

--------------------------------------------------------------------------------

tell me about yourself?


i'm a quick learner, dedicated, hard working and friendly employee.

--------------------------------------------------------------------------------

common mistakes in job interview


poor personal appearance.

lack of interest and enthusiasm: passive and indifferent.


over emphasis on money: interested only in best dollar offer.
condemnation of past employers.
failure to look at the interviewer when conversing.
limp, fishy handshake.
unwillingness to go where sent.
late to interview.
failure to express appreciation for interviewer's time.
asks no questions about job.
indefinite response to questions.
overbearing, over aggressive, conceited with superiority or "know it all complex."
inability to express self clearly: poor voice diction, grammar.
lack of planning for career: no purpose and goals.
lack of confidence and poise: nervous ill at ease.
failure to participate in activities.
unwilling to start at the bottom-expects too much too soon.
makes excuses, evasive, hedges on unfavorable factors in record.
lack of tact.
lack of courtesy: ill mannered.
lack of maturity.
lack of vitality.
indecision.
sloppy application blank.
merely shopping around.
wants job for short time.
no interest in company or industry.
low moral standards.
cynical.
lazy.
intolerant: strong prejudices.
narrow interests.
inability to take criticism.
high pressure type.

--------------------------------------------------------------------------------

here are some other job interview questions you might want to rehearse.
your qualifications

what can you do for us that someone else can't do?


what qualifications do you have that relate to the position?
what new skills or capabilities have you developed recently?
give me an example from a previous job where you've shown initiative.
what have been your greatest accomplishments recently?
what is important to you in a job?
what motivates you in your work?
what have you been doing since your last job?
what qualities do you find important in a coworker?
your career goals

what would you like to being doing five years from now?
how will you judge yourself successful? how will you achieve success?
what type of position are you interested in?
how will this job fit in your career plans?
what do you expect from this job?
do you have a location preference?
can you travel?
what hours can you work?
when could you start?
your work experience

what have you learned from your past jobs?


what were your biggest responsibilities?
what specific skills acquired or used in previous jobs relate to this position?
how does your previous experience relate to this position?
what did you like most/least about your last job?
whom may we contact for references?
your education

how do you think your education has prepared you for this position?
what were your favorite classes/activities at school?
why did you choose your major?
do you plan to continue your education?

--------------------------------------------------------------------------------

what have i forgotten to ask?


use this as a chance to summarize your good characteristics and attributes and how
they may be used to benefit the organization. convince the interviewer that you
understand the job requirements and that you can succeed.

--------------------------------------------------------------------------------

what salary are you expecting?


you probably don't want to answer this one directly. instead, deflect the question
back to the interviewer by saying something like: "i don't know. what are you
planning on paying the best candidate?" let the employer make the first offer.

however, it is still important to know what the current salary range is for the
profession. find salary surveys at the library or on the internet, and check the
classifieds to see what comparable jobs in your area are paying. this information
can help you negotiate compensation once the employer makes an offer.
--------------------------------------------------------------------------------

"what are your hobbies?" and "do you play any sports?"
the interviewer may be looking for evidence of your job skills outside of your
professional experience. for example, hobbies such as chess or bridge demonstrate
analytical skills. reading, music, and painting are creative hobbies. individual
sports show determination and stamina, while group sport activities may indicate
you are comfortable working as part of a team. also, the interviewer might simply
be curious as to whether you have a life outside of work. employees who have
creative or athletic outlets for their stress are often healthier, happier and
more productive.

--------------------------------------------------------------------------------

"what are your career goals?" or "what are your future plans?"
the interviewer wants to know if your plans and the company's goals are
compatible. let him know that you are ambitious enough to plan ahead. talk about
your desire to learn more and improve your performance, and be specific as
possible about how you will meet the goals you have set for yourself.

--------------------------------------------------------------------------------

do you prefer to work by yourself or with others?


the ideal answer is one of flexibility. however, be honest. give examples
describing how you have worked in both situations.

--------------------------------------------------------------------------------

what is your major weakness?


be positive; turn a weakness into a strength. for example, you might say: "i often
worry too much over my work. sometimes i work late to make sure the job is done
well."

--------------------------------------------------------------------------------

what are your best skills?


if you have sufficiently researched the organization, you should be able to
imagine what skills the company values. list them, then give examples where you
have demonstrated these skills.

--------------------------------------------------------------------------------

why did you leave your last job?


the interviewer may want to know if you had any problems on your last job. if you
did not have any problems, simply give a reason, such as: relocated away from job;
company went out of business; laid off; temporary job; no possibility of
advancement; wanted a job better suited to your skills.

if you did have problems, be honest. show that you can accept responsibility and
learn from your mistakes. you should explain any problems you had (or still have)
with an employer, but don't describe that employer in negative terms. demonstrate
that it was a learning experience that will not affect your future work.
--------------------------------------------------------------------------------

"why do you want to work here?" or "what about our company?"


few questions are more important than these, so it is important to answer them
clearly and with enthusiasm. show the interviewer your interest in the company.
share what you learned about the job, the company and the industry through your
own research. talk about how your professional skills will benefit the company.
unless you work in sales, your answer should never be simply: "money." the
interviewer will wonder if you really care about the job.

--------------------------------------------------------------------------------

tell me about yourself.


make a short, organized statement of your education and professional achievements
and professional goals. then, briefly describe your qualifications for the job and
the contributions you could make to the organization.

--------------------------------------------------------------------------------

do you prefer to work alone or in a group?


it depends on the project or the task. i am comfortable working in a group as well
as individually. most of the times, the team effort brings the new and better
concepts. however, there are some tasks that are effectively completed by one
person. if i am trying to identify a production problem, one person can do it
effectively. when some other person is looking over your shoulder, you do not do a
good job.

--------------------------------------------------------------------------------

why should we hire you?


i will be an asset to your organization. i'm loyal, persistent, motivated, and i
learn fast. i am someone who could be very productive very quickly.

--------------------------------------------------------------------------------

what is your favorite color?


purple

--------------------------------------------------------------------------------

why do you like the job?


because i think i have a best quality for that job.

--------------------------------------------------------------------------------

return to top

--------------------------------------------------------------------------------
java language
only the most important questions listed below and they are not categorized, since
your interviewing questions will not be categorized either.

what is a transient variable?


a transient variable is a variable that may not be serialized.

which containers use a border layout as their default layout?


the window, frame and dialog classes use a border layout as their default layout.

how are observer and observable used?


objects that subclass the observable class maintain a list of observers. when an
observable object is updated it invokes the update() method of each of its
observers to notify the observers that it has changed state. the observer
interface is implemented by objects that observe observable objects.

what is synchronization and why is it important?


with respect to multithreading, synchronization is the capability to control the
access of multiple threads to shared resources. without synchronization, it is
possible for one thread to modify a shared object while another thread is in the
process of using or updating that object's value. this often causes dirty data and
leads to significant errors.

what are synchronized methods and synchronized statements?


synchronized methods are methods that are used to control access to an object. a
thread only executes a synchronized method after it has acquired the lock for the
method's object or class. synchronized statements are similar to synchronized
methods. a synchronized statement can only be executed after a thread has acquired
the lock for the object or class referenced in the synchronized statement.

what are three ways in which a thread can enter the waiting state?
a thread can enter the waiting state by invoking its sleep() method, by blocking
on i/o, by unsuccessfully attempting to acquire an object's lock, or by invoking
an object's wait() method. it can also enter the waiting state by invoking its
(deprecated) suspend() method.

can a lock be acquired on a class?


yes, a lock can be acquired on a class. this lock is acquired on the class's class
object.

what's new with the stop(), suspend() and resume() methods in jdk 1.2?
the stop(), suspend() and resume() methods have been deprecated in jdk 1.2.

what is the preferred size of a component?


the preferred size of a component is the minimum component size that will allow
the component to display normally.

what method is used to specify a container's layout?


the setlayout() method is used to specify a container's layout.

which containers use a flowlayout as their default layout?


the panel and applet classes use the flowlayout as their default layout.

what state does a thread enter when it terminates its processing?


when a thread terminates its processing, it enters the dead state.

what is the collections api?


the collections api is a set of classes and interfaces that support operations on
collections of objects.

what is the list interface?


the list interface provides support for ordered collections of objects.

how does java handle integer overflows and underflows?


it uses those low order bytes of the result that can fit into the size of the type
allowed by the operation.

what is the vector class?


the vector class provides the capability to implement a growable array of objects

what modifiers may be used with an inner class that is a member of an outer class?
a (non-local) inner class may be declared as public, protected, private, static,
final, or abstract.

if a method is declared as protected, where may the method be accessed?


a protected method may only be accessed by classes or interfaces of the same
package or by subclasses of the class in which it is declared.

what is an iterator interface?


the iterator interface is used to step through the elements of a collection.

how many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?
unicode requires 16 bits and ascii require 7 bits. although the ascii character
set uses only 7 bits, it is usually represented as 8 bits. utf-8 represents
characters using 8, 16, and 18 bit patterns. utf-16 uses 16-bit and larger bit
patterns.

what is the difference between yielding and sleeping?


when a task invokes its yield() method, it returns to the ready state. when a task
invokes its sleep() method, it returns to the waiting state.

is sizeof a keyword?
the sizeof operator is not a keyword.
what are wrapped classes?
wrapped classes are classes that allow primitive types to be accessed as objects.

does garbage collection guarantee that a program will not run out of memory?
no, it doesn't. it is possible for programs to use up memory resources faster than
they are garbage collected. it is also possible for programs to create objects
that are not subject to garbage collection

what is the difference between preemptive scheduling and time slicing?


under preemptive scheduling, the highest priority task executes until it enters
the waiting or dead states or a higher priority task comes into existence. under
time slicing, a task executes for a predefined slice of time and then reenters the
pool of ready tasks. the scheduler then determines which task should execute next,
based on priority and other factors.

name component subclasses that support painting.


the canvas, frame, panel, and applet classes support painting.

what is a native method?


a native method is a method that is implemented in a language other than java.

how can you write a loop indefinitely?


for(;;)--for loop; while(true)--always true, etc.

can an anonymous class be declared as implementing an interface and extending a


class?
an anonymous class may implement an interface or extend a superclass, but may not
be declared to do both.

what is the purpose of finalization?


the purpose of finalization is to give an unreachable object the opportunity to
perform any cleanup processing before the object is garbage collected.

which class is the superclass for every class.


object

what invokes a thread's run() method?


after a thread is started, via its start() method or that of the thread class, the
jvm invokes the thread's run() method when the thread is initially executed.

what is the difference between the boolean & operator and the && operator?
if an expression involving the boolean & operator is evaluated, both operands are
evaluated. then the & operator is applied to the operand. when an expression
involving the && operator is evaluated, the first operand is evaluated. if the
first operand returns a value of true then the second operand is evaluated. the &&
operator is then applied to the first and second operands. if the first operand
evaluates to false, the evaluation of the second operand is skipped.
operator & has no chance to skip both sides evaluation and && operator does. if
asked why, give details as above.

what is the gregoriancalendar class?


the gregoriancalendar provides support for traditional western calendars.

what is the simpletimezone class?


the simpletimezone class provides support for a gregorian calendar.

which container method is used to cause a container to be laid out and


redisplayed?
validate()

what is the properties class?


the properties class is a subclass of hashtable that can be read from or written
to a stream. it also provides the capability to specify a set of default values to
be used.

what is the purpose of the runtime class?


the purpose of the runtime class is to provide access to the java runtime system.

what is the purpose of the system class?


the purpose of the system class is to provide access to system resources.

what is the purpose of the finally clause of a try-catch-finally statement?


the finally clause is used to provide the capability to execute code no matter
whether or not an exception is thrown or caught.

what is the locale class?


the locale class is used to tailor program output to the conventions of a
particular geographic, political, or cultural region.

what must a class do to implement an interface?


it must provide all of the methods in the interface and identify the interface in
its implements clause.

what is the purpose of the wait(), notify(), and notifyall() methods?


the wait(),notify(), and notifyall() methods are used to provide an efficient way
for threads to communicate each other.

what is an abstract method?


an abstract method is a method whose implementation is deferred to a subclass.

what are the high-level thread states?


the high-level thread states are ready, running, waiting, and dead.
what is the difference between a static and a non-static inner class?
a non-static inner class may have object instances that are associated with
instances of the class's outer class. a static inner class does not have any
object instances.

what is an object's lock and which object's have locks?


an object's lock is a mechanism that is used by multiple threads to obtain
synchronized access to the object. a thread may execute a synchronized method of
an object only after it has acquired the object's lock. all objects and classes
have locks. a class's lock is acquired on the class's class object.

when can an object reference be cast to an interface reference?


an object reference be cast to an interface reference when the object implements
the referenced interface.

what is the difference between a window and a frame?


the frame class extends window to define a main application window that can have a
menu bar.

what do heavy weight components mean?


heavy weight components like abstract window toolkit (awt), depend on the local
windowing toolkit. for example, java.awt.button is a heavy weight component, when
it is running on the java platform for unix platform, it maps to a real motif
button. in this relationship, the motif button is called the peer to the
java.awt.button. if you create two buttons, two peers and hence two motif buttons
are also created. the java platform communicates with the motif buttons using the
java native interface. for each and every component added to the application,
there is an additional overhead tied to the local windowing system, which is why
these components are called heavyweight.

which package has light weight components?


javax.swing package. all components in swing, except japplet, jdialog, jframe and
jwindow are lightweight components.

what are peerless components?


the peerless components are called light weight components.

what is the difference between the font and fontmetrics classes?


the fontmetrics class is used to define implementation-specific properties, such
as ascent and descent, of a font object.

what happens when a thread cannot acquire a lock on an object?


if a thread attempts to execute a synchronized method or synchronized statement
and is unable to acquire an object's lock, it enters the waiting state until the
lock becomes available.

what is the difference between the reader/writer class hierarchy and the
inputstream/outputstream class hierarchy?
the reader/writer class hierarchy is character-oriented, and the
inputstream/outputstream class hierarchy is byte-oriented.

what classes of exceptions may be caught by a catch clause?


a catch clause can catch any exception that may be assigned to the throwable type.
this includes the error and exception types.

if a class is declared without any access modifiers, where may the class be
accessed?
a class that is declared without any access modifiers is said to have package or
friendly access. this means that the class can only be accessed by other classes
and interfaces that are defined within the same package.

what is the map interface?


the map interface replaces the jdk 1.1 dictionary class and is used associate keys
with values.

does a class inherit the constructors of its superclass?


a class does not inherit constructors from any of its superclasses.

name primitive java types.


the primitive types are byte, char, short, int, long, float, double, and boolean.

which class should you use to obtain design information about an object?
the class class is used to obtain information about an object's design.

how can a gui component handle its own events?


a component can handle its own events by implementing the required event-listener
interface and adding itself as its own event listener.

how are the elements of a gridbaglayout organized?


the elements of a gridbaglayout are organized according to a grid. however, the
elements are of different sizes and may occupy more than one row or column of the
grid. in addition, the rows and columns may have different sizes.

what advantage do java's layout managers provide over traditional windowing


systems?
java uses layout managers to lay out components in a consistent manner across all
windowing platforms. since java's layout managers aren't tied to absolute sizing
and positioning, they are able to accommodate platform-specific differences among
windowing systems.

what are the problems faced by java programmers who don't use layout managers?
without layout managers, java programmers are faced with determining how their gui
will be displayed across multiple windowing systems and finding a common sizing
and positioning that will work within the constraints imposed by each windowing
system.
what is the difference between static and non-static variables?
a static variable is associated with the class as a whole rather than with
specific instances of a class. non-static variables take on unique values with
each object instance.

what is the difference between the paint() and repaint() methods?


the paint() method supports painting via a graphics object. the repaint() method
is used to cause paint() to be invoked by the awt painting thread.

what is the purpose of the file class?


the file class is used to create objects that provide access to the files and
directories of a local file system.

how does multithreading take place on a computer with a single cpu?


the operating system's task scheduler allocates execution time to multiple tasks.
by quickly switching between executing tasks, it creates the impression that tasks
execute sequentially.

what restrictions are placed on method overloading?


two methods may not have the same name and argument list but different return
types.

what restrictions are placed on method overriding?


overridden methods must have the same name, argument list, and return type. the
overriding method may not limit the access of the method it overrides. the
overriding method may not throw any exceptions that may not be thrown by the
overridden method.

what is casting?
there are two types of casting, casting between primitive numeric types and
casting between object references. casting between numeric types is used to
convert larger values, such as double values, to smaller values, such as byte
values. casting between object references is used to refer to an object by a
compatible class, interface, or array type reference.

name container classes.


window, frame, dialog, filedialog, panel, applet, or scrollpane

what class allows you to read objects directly from a stream?


the objectinputstream class supports the reading of objects from input streams.

how are this() and super() used with constructors?


this() is used to invoke a constructor of the same class. super() is used to
invoke a superclass constructor.

how is it possible for two string objects with identical values not to be equal
under the == operator?
the == operator compares two objects to determine if they are the same object in
memory. it is possible for two string objects to have the same value, but located
indifferent areas of memory.

what an i/o filter?


an i/o filter is an object that reads from one stream and writes to another,
usually altering the data in some way as it is passed from one stream to another.

what is the set interface?


the set interface provides methods for accessing the elements of a finite
mathematical set. sets do not allow duplicate elements.

what is the list interface?


the list interface provides support for ordered collections of objects.

what is the purpose of the enableevents() method?


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

what is the difference between the file and randomaccessfile classes?


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

what interface must an object implement before it can be written to a stream as an


object?
an object must implement the serializable or externalizable interface before it
can be written to a stream as an object.

what is the resourcebundle class?


the resourcebundle class is used to store locale-specific resources that can be
loaded by a program to tailor the program's appearance to the particular locale in
which it is being run.

what is the difference between a scrollbar and a scrollpane?


a scrollbar is a component, but not a container. a scrollpane is a container. a
scrollpane handles its own events and performs its own scrolling.

what is a java package and how is it used?


a java package is a naming context for classes and interfaces. a package is used
to create a separate name space for groups of classes and interfaces. packages are
also used to organize related classes and interfaces into a single api unit and to
control accessibility to these classes and interfaces.

what are the object and class classes used for?


the object class is the highest-level class in the java class hierarchy. the class
class is used to represent the classes and interfaces that are loaded by a java
program.

what is serialization and deserialization?


serialization is the process of writing the state of an object to a byte stream.
deserialization is the process of restoring these objects.

what is tunnelling?
tunnelling is a route to somewhere. for example, rmi tunnelling is a way to make
rmi application get through firewall. in cs world, tunnelling means a way to
transfer data.

does the code in finally block get executed if there is an exception and a retrun
statement in a catch block?
if an exception occurs and there is a return statement in catch block, the finally
block is still executed. the finally block will not be executed when the
system.exit(1) statement is executed earlier or the system shut down earlier or
the memory is used up earlier before the thread goes to finally block.

how you restrict a user to cut and paste from the html page ?
using javascript to lock keyboard keys. it is one of solutions.

is java a super set of javascript ?


no. they are completely different. some syntax may be similar.

return to top

--------------------------------------------------------------------------------

networking
sockets & rmi

what is the difference between url instance and urlconnection instance?


a url instance represents the location of a resource, and a urlconnection instance
represents a link for accessing or communicating with the resource at the
location.

how do i make a connection to url?


you obtain a url instance and then invoke openconnection on it. urlconnection is
an abstract class, which means you can't directly create instances of it using a
constructor. we have to invoke openconnection method on a url instance, to get the
right kind of connection for your url. eg. url url;

urlconnection connection;
try{ url = new url("...");
connection = url.openconnection();
}catch (malformedurlexception e) { }
what is a socket?
a socket is one end-point of a two-way communication link between two programs
running on the network. a socket is bound to a port number so that the tcp layer
can identify the application that data is destined to be sent. socket classes are
used to represent the connection between a client program and a server program.
the java.net package provides two classes--socket and serversocket--which
implement the client side of the connection and the server side of the connection,
respectively.

what information is needed to create a tcp socket?


the local system�s ip address and port number. and the remote system's ipaddress
and port number.

what are the two important tcp socket classes?


socket and serversocket. serversocket is used for normal two-way socket
communication. socket class allows us to read and write through the sockets.
getinputstream() and getoutputstream() are the two methods available in socket
class.

when malformedurlexception and unknownhostexception throws?


when the specified url is not connected then the url throw malformedurlexception
and if inetaddress� methods getbyname and getlocalhost are unable to resolve the
host name they throw an unknownhostexception.

what does rmi stand for?


it stands for remote method invocation.

what is rmi?
rmi is a set of apis that allows to build distributed applications. rmi uses
interfaces to define remote objects to turn local method invocations into remote
method invocations.

return to top

--------------------------------------------------------------------------------

jdbc
what is jdbc?
jdbc is a layer of abstraction that allows users to choose between databases. it
allows you to change to a different database engine and to write to a single api.
jdbc allows you to write database applications in java without having to concern
yourself with the underlying details of a particular database.

what are the two major components of jdbc?


one implementation interface for database manufacturers, the other implementation
interface for application and applet writers.

what is jdbc driver interface?


the jdbc driver interface provides vendor-specific implementations of the abstract
classes provided by the jdbc api. each vendors driver must provide implementations
of the java.sql.connection,statement,preparedstatement, callablestatement,
resultset and driver.

what are the common tasks of jdbc?


1.create an instance of a jdbc driver or load jdbc drivers through jdbc.drivers;
2. register a driver; 3. specify a database; 4. open a database connection; 5.
submit a query; 6. receive results.

what packages are used by jdbc?


there are 8 packages: java.sql.driver, connection,statement, preparedstatement,
callablestatement, resultset, resultsetmetadata, databasemetadata.

what are the flow statements of jdbc?


a url string -->getconnection-->drivermanager-->driver-->connection-->statement--
>executequery-->resultset.

what are the steps involved in establishing a connection?


this involves two steps: (1) loading the driver and (2) making the connection.

how can you load the drivers?


loading the driver or drivers you want to use is very simple and involves just one
line of code. if, for example, you want to use the jdbc-odbc bridge driver, the
following code will load it:

eg.
class.forname("sun.jdbc.odbc.jdbcodbcdriver");

your driver documentation will give you the class name to use. for instance, if
the class name is jdbc.driverxyz , you would load the driver with the following
line of code:
e.g.
class.forname("jdbc.driverxyz");

what class.forname will do while loading drivers?


it is used to create an instance of a driver and register it with the
drivermanager. when you have loaded a driver, it is available for making a
connection with a dbms.

how can you make the connection?


in establishing a connection is to have the appropriate driver connect to the
dbms. the following line of code illustrates the general idea:

e.g.
string url = "jdbc:odbc:fred";
connection con = drivermanager.getconnection(url, "fernanda", "j8");

how can you create jdbc statements?


a statement object is what sends your sql statement to the dbms. you simply create
a statement object and then execute it, supplying the appropriate execute method
with the sql statement you want to send. for a select statement, the method to use
is executequery. for statements that create or modify tables, the method to use is
executeupdate. e.g. it takes an instance of an active connection to create a
statement object. in the following example, we use our connection object con to
create the statement object stmt :

statement stmt = con.createstatement();

how can you retrieve data from the resultset?


first jdbc returns results in a resultset object, so we need to declare an
instance of the class resultset to hold our results. the following code
demonstrates declaring the resultset object rs.

e.g.
resultset rs = stmt.executequery("select cof_name, price from coffees");

second:
string s = rs.getstring("cof_name");

the method getstring is invoked on the resultset object rs , so getstring will


retrieve (get) the value stored in the column cof_name in the current row of rs

what are the different types of statements?


1.statement (use createstatement method) 2. prepared statement (use
preparestatement method) and 3. callable statement (use preparecall)

how can you use preparedstatement?


this special type of statement is derived from the more general class, statement.
if you want to execute a statement object many times, it will normally reduce
execution time to use a preparedstatement object instead. the advantage to this is
that in most cases, this sql statement will be sent to the dbms right away, where
it will be compiled. as a result, the preparedstatement object contains not just
an sql statement, but an sql statement that has been precompiled. this means that
when the preparedstatement is executed, the dbms can just run the
preparedstatement 's sql statement without having to compile it first.

e.g.
preparedstatement updatesales = con.preparestatement("update coffees set sales = ?
where cof_name like ?");

how to call a stored procedure from jdbc?


the first step is to create a callablestatement object. as with statement an and
preparedstatement objects, this is done with an open connection object. a
callablestatement object contains a call to a stored procedure;

e.g.
callablestatement cs = con.preparecall("{call show_suppliers}");
resultset rs = cs.executequery();
how to retrieve warnings?
sqlwarning objects are a subclass of sqlexception that deal with database access
warnings. warnings do not stop the execution of an application, as exceptions do;
they simply alert the user that something did not happen as planned. a warning can
be reported on a connection object, a statement object (including
preparedstatement and callablestatement objects), or a resultset object. each of
these classes has a getwarnings method, which you must invoke in order to see the
first warning reported on the calling object

e.g.
sqlwarning warning = stmt.getwarnings();
if (warning != null) {

while (warning != null) {


system.out.println("message: " + warning.getmessage());
system.out.println("sqlstate: " + warning.getsqlstate());
system.out.print("vendor error code: ");
system.out.println(warning.geterrorcode());
warning = warning.getnextwarning();
}
}

how to make updates to updatable result sets?


another new feature in the jdbc 2.0 api is the ability to update rows in a result
set using methods in the java programming language rather than having to send an
sql command. but before you can take advantage of this capability, you need to
create a resultset object that is updatable. in order to do this, you supply the
resultset constant concur_updatable to the createstatement method.

e.g.
connection con = drivermanager.getconnection("jdbc:mysubprotocol:mysubname");
statement stmt = con.createstatement(resultset.type_scroll_sensitive,
resultset.concur_updatable);
resultset uprs = ("select cof_name, price from coffees");

return to top

--------------------------------------------------------------------------------

jsp
what is jsp technology?
java server page is a standard java extension that is defined on top of the
servlet extensions. the goal of jsp is the simplified creation and management of
dynamic web pages. jsps are secure, platform-independent, and best of all, make
use of java as a server-side scripting language.

what is jsp page?


a jsp page is a text-based document that contains two types of text: static
template data, which can be expressed in any text-based format such as html, svg,
wml, and xml, and jsp elements, which construct dynamic content.
what are the implicit objects?
implicit objects are created by the web container and contain information related
to a particular request, page, or application. they are request, response,
pagecontext, session, application, out, config, page and exception.

how many jsp scripting elements and what are they?


there are three scripting language elements: declarations, scriptlets, and
expressions.

why are jsp pages the preferred api for creating a web-based client program?
because no plug-ins or security policy files are needed on the client
systems(applet does). also, jsp pages enable cleaner and more module application
design because they provide a way to separate applications programming from web
page design. this means personnel involved in web page design do not need to
understand java programming language syntax to do their jobs.

is jsp technology extensible?


yes. jsp technology is extensible through the development of custom actions, or
tags, which are encapsulated in tag libraries.

what are the two kinds of comments in jsp and whats the difference between them
<%-- jsp comment --%>
<!-- html comment -->

return to top

--------------------------------------------------------------------------------

servlet
what is the servlet?
servlets are modules that extend request/response-oriented servers, such as java-
enabled web servers. for example, a servlet may be responsible for taking data in
an html order-entry form and applying the business logic used to update a
company's order database.

what's the difference between servlets and applets?


servlets are to servers; applets are to browsers. unlike applets, however,
servlets have no graphical user interface.

what's the advantages using servlets than using cgi?


servlets provide a way to generate dynamic documents that is both easier to write
and faster to run. it is efficient, convenient, powerful, portable, secure and
inexpensive. servlets also address the problem of doing server-side programming
with platform-specific apis: they are developed with java servlet api, a standard
java extension.
what are the uses of servlets?
a servlet can handle multiple requests concurrently, and can synchronize requests.
this allows servlets to support systems such as on-line conferencing. servlets can
forward requests to other servers and servlets. thus servlets can be used to
balance load among several servers that mirror the same content, and to partition
a single logical service over several servers, according to task type or
organizational boundaries.

what's the servlet interface?


the central abstraction in the servlet api is the servlet interface. all servlets
implement this interface, either directly or, more commonly, by extending a class
that implements it such as httpservlet. servlets-->generic servlet-->httpservlet--
>myservlet. the servlet interface declares, but does not implement, methods that
manage the servlet and its communications with clients. servlet writers provide
some or all of these methods when developing a servlet.

when a servlet accepts a call from a client, it receives two objects. what are
they?
serveltrequest: which encapsulates the communication from the client to the
server.
servletresponse: which encapsulates the communication from the servlet back to the
client.
servletrequest and servletresponse are interfaces defined by the javax.servlet
package.

what information that the servletrequest interface allows the servlet access to?
information such as the names of the parameters passed in by the client, the
protocol (scheme) being used by the client, and the names of the remote host that
made the request and the server that received it. the input stream,
servletinputstream.servlets use the input stream to get data from clients that use
application protocols such as the http post and put methods.

what information that the servletresponse interface gives the servlet methods for
replying to the client?
it allows the servlet to set the content length and mime type of the reply.
provides an output stream, servletoutputstream and a writer through which the
servlet can send the reply data.

if you want a servlet to take the same action for both get and post request, what
you should do?
simply have doget call dopost, or vice versa.

what is the servlet life cycle?


each servlet has the same life cycle:
a server loads and initializes the servlet (init())
the servlet handles zero or more client requests (service())
the server removes the servlet (destroy()) (some servers do this step only when
they shut down)

which code line must be set before any of the lines that use the printwriter?
setcontenttype() method must be set before transmitting the actual document.
how http servlet handles client requests?
an http servlet handles client requests through its service method. the service
method supports standard http client requests by dispatching each request to a
method designed to handle that request.

when using servlets to build the html, you build a doctype line, why do you do
that?
i know all major browsers ignore it even though the html 3.2 and 4.0
specifications require it. but building a doctype line tells html validators which
version of html you are using so they know which specification to check your
document against. these validators are valuable debugging services, helping you
catch html syntax errors.(http://validator.w3.org and
http://www.htmlhelp.com/tools/validator/ are two major online validators)

what is servletcontext?
-

return to top

--------------------------------------------------------------------------------

ejb
what is ejb?
ejb stands for enterprise javabean and is the widely-adopted server side component
architecture for j2ee. it enables rapid development of mission-critical
application that are versatile, reusable and portable across middleware while
protecting it investment and preventing vendor lock-in.

what is ejb role in j2ee?


ejb technology is the core of j2ee. it enables developers to write reusable and
portable server-side business logic for the j2ee platform.

what is the difference between ejb and java beans?


ejb is a specification for j2ee server, not a product; java beans may be a
graphical component in ide.

what are the key features of the ejb technology?

ejb components are server-side components written entirely in the java programming
language
ejb components contain business logic only - no system-level programming &
services, such as transactions, security, life-cycle, threading, persistence, etc.
are automatically managed for the ejb component by the ejb server.
ejb architecture is inherently transactional, distributed, portable multi-tier,
scalable and secure.
ejb components are fully portable across any ejb server and any os.
ejb architecture is wire-protocol neutral--any protocol can be utilized like
iiop,jrmp, http, dcom,etc.
what are the key benefits of the ejb technology?

rapid application development


broad industry adoption
application portability
protection of it investment

how many enterprice beans?


there are three kinds of enterprise beans:

session beans,
entity beans, and
message-driven beans.

what is message-driven bean?


a message-driven bean combines features of a session bean and a java message
service (jms) message listener, allowing a business component to receive jms. a
message-driven bean enables asynchronous clients to access the business logic in
the ejb tier.

what is entity bean and session bean ?


entity bean is a java class which implements an enterprise bean interface and
provides the implementation of the business methods. there are two types:
container managed persistence(cmp) and bean-managed persistence(bmp).
session bean is used to represent a workflow on behalf of a client. there are two
types: stateless and stateful. stateless bean is the simplest bean. it doesn't
maintain any conversational state with clients between method invocations.
stateful bean maintains state between invocations.

return to top

--------------------------------------------------------------------------------

j2ee
what is j2ee?
j2ee is an environment for developing and deploying enterprise applications. the
j2ee platform consists of a set of services, application programming interfaces
(apis), and protocols that provide the functionality for developing multitiered,
web-based applications.

what are the components of j2ee application?


a j2ee component is a self-contained functional software unit that is assembled
into a j2ee application with its related classes and files and communicates with
other components. the j2ee specification defines the following j2ee components:

application clients and applets are client components.


java servlet and javaserver pagestm (jsptm) technology components are web
components.
enterprise javabeanstm (ejbtm) components (enterprise beans) are business
components.
resource adapter components provided by eis and tool vendors.
is j2ee application only a web-based?
no. a j2ee application can be web-based or non-web-based. if an application client
executes on the client machine, it is a non-web-based j2ee application. the j2ee
application can provide a way for users to handle tasks such as j2ee system or
application administration. it typically has a graphical user interface created
from swing or awt apis, or a command-line interface. when user request, it can
open an http connection to establish communication with a servlet running in the
web tier.

are javabeans j2ee components?


no. javabeans components are not considered j2ee components by the j2ee
specification. javabeans components written for the j2ee platform have instance
variables and get and set methods for accessing the data in the instance
variables. javabeans components used in this way are typically simple in design
and implementation, but should conform to the naming and design conventions
outlined in the javabeans component architecture.

is html page a web component?


no. static html pages and applets are bundled with web components during
application assembly, but are not considered web components by the j2ee
specification. even the server-side utility classes are not considered web
components,either.

what is the container?


a container is a runtime support of a system-level entity. containers provide
components with services such as lifecycle management, security, deployment, and
threading.

what is the web container?


servlet and jsp containers are collectively referred to as web containers.

what is the thin client?


a thin client is a lightweight interface to the application that does not have
such operations like query databases, execute complex business rules, or connect
to legacy applications.

what are types of j2ee clients?


applets
application clients
java web start-enabled rich clients, powered by java web start technology.
wireless clients, based on mobile information device profile (midp) technology.

what is deployment descriptor?


a deployment descriptor is an extensible markup language (xml) text-based file
with an .xml extension that describes a component's deployment settings. a j2ee
application and each of its modules has its own deployment descriptor.

what is the ear file?


an ear file is a standard jar file with an .ear extension, named from enterprice
archive file. a j2ee application with all of its modules is delivered in ear file.
what is jta and jts?
jta is the abbreviation for the java transaction api. jts is the abbreviation for
the jave transaction service. jta provides a standard interface and allows you to
demarcate transactions in a manner that is independent of the transaction manager
implementation. the j2ee sdk implements the transaction manager with jts. but your
code doesn't call the jts methods directly. instead, it invokes the jta methods,
which then call the lower-level jts routines.

therefore, jta is a high level transaction interface that your application uses to
control transaction. and jts is a low level transaction interface and ejb uses
behind the scenes (client code doesn't directly interact with jts. it is based on
object transaction service(ots) which is part of corba.

what is jaxp?
jaxp stands for java api for xml. xml is a language for representing and
describing text-based data which can be read and handled by any program or tool
that uses xml apis.

what is j2ee connector?


the j2ee connector api is used by j2ee tools vendors and system integrators to
create resource adapters that support access to enterprise information systems
that can be plugged into any j2ee product. each type of database or eis has a
different resource adapter.

what is jaap?
the java authentication and authorization service (jaas) provides a way for a j2ee
application to authenticate and authorize a specific user or group of users to run
it. it is a standard pluggable authentication module (pam) framework that extends
the java 2 platform security architecture to support user-based authorization.

what is model 1?
using jsp technology alone to develop web page. such term is used in the earlier
jsp specification. model 1 architecture is suitable for applications that have
very simple page flow, have little need for centralized security control or
logging, and change little over time. model 1 applications can often be refactored
to model 2 when application requirements change.

what is model 2?
using jsp and servelet together to develop web page. model 2 applications are
easier to maintain and extend, because views do not refer to each other directly.

what is struts?
a web page development framework. struts combines java servlets, java server
pages, custom tags, and message resources into a unified framework. it is a
cooperative, synergistic platform, suitable for development teams, independent
developers, and everyone between.

how is the mvc design pattern used in struts framework?


in the mvc design pattern, application flow is mediated by a central controller.
the controller delegates requests to an appropriate handler. the handlers are tied
to a model, and each handler acts as an adapter between the request and the model.
the model represents, or encapsulates, an application's business logic or state.
control is usually then forwarded back through the controller to the appropriate
view. the forwarding can be determined by consulting a set of mappings, usually
loaded from a database or configuration file. this provides a loose coupling
between the view and model, which can make an application significantly easier to
create and maintain.

controller--servlet controller which supplied by struts itself; view --- what you
can see on the screen, a jsp page and presentation components; model --- system
state and a business logic javabeans.

do you have to use design pattern in j2ee project?


yes. if i do it, i will use it. learning design pattern will boost my coding
skill.

is j2ee a super set of j2se?


yes

return to top

--------------------------------------------------------------------------------

jms
java message service is the new standard for interclient communication. it allows
j2ee application components to create, send, receive, and read messages. it
enables distributed communication that is loosely coupled, reliable, and
asynchronous.

return to top

--------------------------------------------------------------------------------

misc
what is wml?
wireless markup language (wml) page is delivered over wireless application
protocol (wap) and the network configuration requires a gateway to translate wap
to http and back again. it can be generated by a jsp page or servlet running on
the j2ee server.

what is your favorite sport?


my answer would be football if the interviewer is a man.

what is junit?
junit is a unit-testing framework. unit-testing is a means of verifying the
results you expect from your classes. if you write your test before hand and focus
your code on passing the test you are more likely to end up with simple code that
does what it should and nothing more. unit-testing also assists in the refactoring
process. if your code passes the unit-test after refactoring you will know that
you haven't introduced any bugs to it.

what is the difference between java and pl/sql?


java is a general programming language. pl/sql is a database query languague,
especially for oracle database.

You might also like