Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Title: 101 BEST JAVA INTERVIEW QUESTIONS AND ANSWERS
Description: Want to crack Core Java Interview? This PDF will guide you.
Description: Want to crack Core Java Interview? This PDF will guide you.
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
101 BEST JAVA INTERVIEW QUESTIONS AND ANSWERS
1
...
In OOP program, unit of program is object, which is nothing but combination of data and code
...
2
...
Inheritance is the process by which one object acquires the properties of another object
...
3
...
4
...
e
...
An object-oriented program can be characterized as data controlling
5
...
What are Class, Constructor and Primitive data types?- Class is a template for multiple objects with
similar features and it is a blue print for objects
...
Constructor is a special kind of method that determines
how an object is initialized when created
...
6
...
that data
...
What is the difference between constructor and method?- Constructor will be automatically
8
...
What are methods and how are they defined?- Methods are functions that operate on instances of
classes in which they are defined
...
Method definition has four parts
...
A method’s signature is a
combination of the first three parts mentioned above
...
What is the use of bin and lib in JDK?- Bin contains all tools such as javac, appletviewer, awt tool, etc
...
10
...
11
...
They are passing by value and passing by reference
...
Passing by reference:
In this method, a reference to an argument (not the value of the argument) is passed to the parameter
...
What is the difference between an argument and a parameter?- While defining method, variables
passed in the method are called parameters
...
13
...
private: Any thing declared as private can’t be seen outside of its class
...
default modifier : Can be accessed only to classes in the same package
...
What is final, finalize() and finally?- final : final keyword can be used for class, method and variables
...
A final method can’t be overridden
...
finalize() : finalize() method is used just before an object is destroyed and can be called just
prior to garbage collection
...
The finally block will execute whether or not an exception is thrown
...
This finally keyword is designed to address this contingency
...
What is UNICODE?- Unicode is used for internal representation of characters and strings and it uses 16
bits to represent each other
...
What is Garbage Collection and how to call it explicitly?- When an object is no longer referred to by
any variable, java automatically reclaims memory used by that object
...
System
...
17
...
18
...
Transient variables are not serialized
...
19
...
Method
overriding : When a method in a class having the same method name with same arguments is said to be
method overriding
...
What is difference between overloading and overriding?- a) In overloading, there is a relationship
between methods available in the same class whereas in overriding, there is relationship between a
superclass method and subclass method
...
c) In overloading, separate methods share the
same name whereas in overriding, subclass method replaces the superclass
...
21
...
The advantages of inheritance are reusability of code and accessibility of
variables and methods of the super class by subclasses
...
What is the difference between this() and super()?- this() can be used to invoke a constructor of the
same class whereas super() can be used to invoke a super class constructor
...
What is the difference between superclass and subclass?- A super class is a class that is inherited
whereas sub class is a class that does the inheriting
...
What modifiers may be used with top-level class?- public, abstract and final can be used for top-level
class
...
What are inner class and anonymous class?- Inner class : classes defined in other classes, including
those defined in methods are called inner classes
...
Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated
and declared in the same place and cannot have explicit constructors
...
What is a package?- A package is a collection of classes and interfaces that provides a high-level layer of
access protection and name space management
...
What is a reflection package?- java
...
reflect package has the ability to analyze itself in runtime
...
What is interface and its use?- Interface is similar to a class which may contain method’s signature only
but not bodies and it is a formal set of method and constant declarations that must be defined by the class
that implements it
...
c)Determining an object’s programming interface without revealing the actual body of the class
...
What is an abstract class?- An abstract class is a class designed with implementation gaps for subclasses
to fill in and is deliberately incomplete
...
What is the difference between Integer and int?- a) Integer is a class defined in the java
...
Java does not automatically
convert from one to the other
...
31
...
32
...
b) In abstract class, key word abstract must be used for the methods whereas interface
we need not use that keyword for the methods
...
33
...
34
...
b) String class supports constant strings whereas
StringBuffer class supports growable and modifiable strings
...
What is the difference between Array and vector?- Array is a set of related data type and static
whereas vector is a growable array of objects and dynamic
...
What is the difference between exception and error?- The exception class defines mild error
conditions that your program encounters
...
The error class defines serious error conditions that you
should not attempt to recover from
...
37
...
38
...
wait (), notify () and notifyAll() methods
can be used for inter-thread communication and these methods are in Object class
...
notify() or
notifyAll() : To remove a thread from the waiting state, some other thread must make a call to notify() or
notifyAll() method on the same object
...
What is the class and interface in java to create thread and which is the most advantageous
method?- Thread class and Runnable interface can be used to create threads and using Runnable interface
is the most advantageous method to create threads because we need not extend thread class here
...
What are the states associated in the thread?- Thread contains ready, running, waiting and dead
states
...
What is synchronization?- Synchronization is the mechanism that ensures that only one thread is
accessed the resources at a time
...
When you will synchronize a piece of your code?- When you expect your code will be accessed by
different threads and these threads may change a particular data causing data corruption
...
What is deadlock?- When two threads are waiting each other and can’t precede the program is said to be
deadlock
...
What is daemon thread and which method is used to create the daemon thread?- Daemon
thread is a low priority thread which runs intermittently in the back ground doing the garbage collection
operation for the java runtime system
...
45
...
Global variables is not possible because concept
of encapsulation is eliminated here
...
What is an applet?- Applet is a dynamic and interactive program that runs inside a web page displayed by
a java capable browser
...
What is the difference between applications and applets?- a)Application must be run on local
machine whereas applet needs no explicit installation on local machine
...
d)Application starts execution with its main method whereas applet starts execution with
its init method
...
48
...
49
...
50
...
paint() method - Can be called when the applet is
minimized or maximized
...
destroy() method - Can be called when the browser is finished with the applet
...
How do you set security in applets?- using setSecurityManager() method
52
...
In other words, event occurs when an action is generated,
like pressing button, clicking mouse, selecting a list, etc
...
What are the advantages of the model over the event-inheritance model?- The event-delegation
model has two advantages over the event-inheritance model
...
This allows a clean separation between a component’s design
and its use
...
This performance
improvement is due to the fact that the event-delegation model does not have to be repeatedly process
unhandled events as is the case of the event-inheritance
...
What is source and listener?- source : A source is an object that generates an event
...
listener : A listener is an object that is notified when an
event occurs
...
First, it must have been registered with one or more sources to
receive notifications about specific types of events
...
55
...
Adapter classes are useful when you want to receive and process only some of the events
that are handled by a particular event listener interface
...
For
example, the MouseMotionAdapter class has two methods, mouseDragged()and mouseMoved()
...
If you are interested
in only mouse drag events, then you could simply extend MouseMotionAdapter and implement
mouseDragged()
...
What is meant by controls and what are different types of controls in AWT?- Controls are
components that allow a user to interact with your application and the AWT supports the following types of
controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components
...
57
...
A List may be displayed in such a way that several list items are visible and it supports the selection
of one or more list items
...
What is the difference between scrollbar and scrollpane?- A Scrollbar is a Component, but not a
Container whereas Scrollpane is a Conatiner and handles its own events and perform its own scrolling
...
What is a layout manager and what are different types of layout managers available in java
AWT?- A layout manager is an object that is used to organize components in a container
...
60
...
BorderLayout: The elements of a BorderLayout are
organized at the borders (North, South, East and West) and the center of a container
...
GridLayout: The elements of a
GridLayout are of equal size and are laid out using the square of a grid
...
However, the elements are of different size and may
occupy more than one row or column of the grid
...
61
...
62
...
63
...
64
...
Hashtable : The Hashtable class implements a
Hashtable data structure
...
Hash codes are integer values that identify objects
...
A LinkedList stores each object in a
separate link whereas an array stores object references in consecutive locations
...
It has two methods,
namely hasMoreElements() and nextElement()
...
65
...
66
...
There are two types of Streams and they are: Byte
Streams: Provide a convenient means for handling input and output of bytes
...
Byte Streams classes: Are defined by using two
abstract classes, namely InputStream and OutputStream
...
67
...
68
...
69
...
Deserialization is the process of restoring these objects
...
What is JDBC?- JDBC is a set of Java API for executing SQL statements
...
71
...
What is the difference between JDBC and ODBC?- a) OBDC is for Microsoft and JDBC is for Java
applications
...
c) ODBC makes use of
pointers which have been removed totally from Java
...
But JDBC is designed to keep things simple while allowing
advanced capabilities when required
...
JDBC drivers are written in Java and JDBC code is automatically installable,
secure, and portable on all platforms
...
JDBC
retains some of the basic features of ODBC
...
What are the types of JDBC Driver Models and explain them?- There are two types of JDBC Driver
Models and they are: a) Two tier model and b) Three tier model Two tier model: In this model, Java
applications interact directly with the database
...
SQL statements are sent to the database and
the results are given to user
...
Three tier model: A middle tier is introduced in
this model
...
74
...
forName() method is used
...
forName(”sun
...
odbc
...
sql
...
b) Making a connection with database: To open a
connection to a given database, DriverManager
...
Connection con =
DriverManager
...
sql
...
createStatement() method of Connection to obtain a
new Statement object
...
createStatement(); A query that returns data can be executed
using the executeQuery() method of Statement
...
sql
...
executeQuery(”SELECT * FROM some
table”); d) Process the results : ResultSet returns one row at a time
...
The getString() and getObject() methods are used for retrieving column
values: while(rs
...
getString(”event”); Object count = (Integer) rs
...
What type of driver did you use in project?- JDBC-ODBC Bridge driver (is a driver that uses native(C
language) libraries and makes calls to an existing ODBC driver to access a database engine)
...
What are the types of statements in JDBC?- Statement: to be used createStatement() method for
executing single SQL statement PreparedStatement — To be used preparedStatement() method for executing
same SQL statement over and over
...
77
...
Stored Procedures are used to encapsulate a set of operations or queries to
execute on database
...
78
...
prepareCall(”{call procedure name(?,?)}”); csmt
...
, data type); csmt
...
, column name) csmt
...
What is servlet?- Servlets are modules that extend request/response-oriented servers, such as javaenabled web servers
...
80
...
servlet and
81
...
b) Applets must have graphical user interfaces whereas servlets have no graphical user
interfaces
...
What is the difference between doPost and doGet methods?- a) doGet() method is used to get
information, while doPost() method is used for posting information
...
However, doPost()requests passes all of its
data, of unlimited length
...
83
...
b) The servlet handles zero or more client’s requests through service() method
...
84
...
What are the different servers available for developing and deploying Servlets?- a) Java Web
Server b) JRun g) Apache Server h) Netscape Information Server i) Web Logic
86
...
87
...
The methods used for session tracking are: a) User Authentication - occurs when a web server
restricts access to some of its resources to only those clients that log in using a recognized username and
password
...
When the form containing the fields is submitted, the fields are sent back to the server
...
The extra information can be in the form of extra path information, added parameters or some
custom, server-specific URL change
...
e) HttpSession- places a limit on the number of
sessions that can exist in memory
...
maxresidents property
...
What is Server-Side Includes (SSI)?- Server-Side Includes allows embedding servlets within HTML
pages using a special servlet tag
...
This is accomplished using a special
internal SSINCLUDE, which processes the servlet tags
...
shtml extension is requested
...
shtml extension
...
What are cookies and how will you use them?- Cookies are a mechanism that a servlet uses to have a
client hold a small amount of state-information associated with the user
...
addCookie(Cookie cookie) c) A servlet retrieves cookies by calling the getCookies() method of
HttpServletRequest: public Cookie[ ] HttpServletRequest
...
90
...
What is connection pooling?- With servlets, opening a database connection is a major bottleneck
because we are creating and tearing down a new connection for every page request and the time taken to
create connection will be more
...
With a connection pool, we can duplicate only the resources we need to duplicate rather than the entire
servlet
...
A number of connection pool packages are currently available
...
The ConnectionPool class maintains a Hastable, using
Connection objects as keys and Boolean values as stored values
...
A program calls getConnection() method of the ConnectionPool for getting
Connection object it can use; it calls returnConnection() to give the connection back to the pool
...
Why should we go for interservlet communication?- Servlets running together in the same server
communicate with each other in several ways
...
c) Servlet collaboration - requires to communicate with each other by sharing
specific information (through method invocation)
93
...
You can call a servlet with parameters
in the syntax as (?Param1 = xxx || m2 = yyy)
...
What is Servlet chaining?- Servlet chaining is a technique in which two or more servlets can cooperate in
servicing a single request
...
This
process continues until the last servlet is reached
...
95
...
When a request comes in, it is assigned to a thread, which calls a service
method (for example: doGet(), doPost() and service()) of the servlet
...
96
...
It is like a phone call
...
It is
like a postal mail
...
What is Inet address?- Every computer connected to a network has an IP address
...
An IP address is a 32-bit number
...
What is Domain Naming Service(DNS)?- It is very difficult to remember a set of numbers(IP address)
to connect to the Internet
...
It maps one
particular IP address to a string of characters
...
mascom
...
99
...
URL has four components: http://www
...
com:80/index
...
html - file path
...
What is RMI and steps involved in developing an RMI object?- Remote Method Invocation (RMI)
allows java object that executes on one machine and to invoke the method of a Java object to execute on
another machine
...
What is RMI architecture?- RMI architecture consists of four layers and each layer performs specific
functions: a) Application layer - contains the actual object definition
...
c) Remote Reference layer - gets the stream of bytes from the transport layer and sends it to the
proxy layer
...
Title: 101 BEST JAVA INTERVIEW QUESTIONS AND ANSWERS
Description: Want to crack Core Java Interview? This PDF will guide you.
Description: Want to crack Core Java Interview? This PDF will guide you.