Skip to main content

Java J2EE Interview Questions and Answers - Part 5

  1. Which containers use a Border layout as their default layout?- Window, Frame and Dialog classes use a BorderLayout as their layout.
  2. Which containers use a Flow layout as their default layout?- Panel and Applet classes use the FlowLayout as their default layout.
  3. What are wrapper classes?- Wrapper classes are classes that allow primitive types to be accessed as objects.
  1. What are Vector, Hashtable, LinkedList and Enumeration?- Vector : The Vector class provides the capability to implement a growable array of objects. Hashtable : The Hashtable class implements a Hashtable data structure. A Hashtable indexes and stores objects in a dictionary using hash codes as the object’s keys. Hash codes are integer values that identify objects. LinkedList: Removing or inserting elements in the middle of an array can be done using LinkedList. A LinkedList stores each object in a separate link whereas an array stores object references in consecutive locations. Enumeration: An object that implements the Enumeration interface generates a series of elements, one at a time. It has two methods, namely hasMoreElements() and nextElement(). HasMoreElemnts() tests if this enumeration has more elements and nextElement method returns successive elements of the series.
  2. What is the difference between set and list?- Set stores elements in an unordered way but does not contain duplicate elements, whereas list stores elements in an ordered way but may contain duplicate elements.
  3. What is a stream and what are the types of Streams and classes of the Streams?- A Stream is an abstraction that either produces or consumes information. There are two types of Streams and they are: Byte Streams: Provide a convenient means for handling input and output of bytes. Character Streams: Provide a convenient means for handling input & output of characters. Byte Streams classes: Are defined by using two abstract classes, namely InputStream and OutputStream. Character Streams classes: Are defined by using two abstract classes, namely Reader and Writer.
  1. What is the difference between Reader/Writer and InputStream/Output Stream?- The Reader/Writer class is character-oriented and the InputStream/OutputStream class is byte-oriented.
  2. What is 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.
  3. 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.
  1. What is JDBC?- JDBC is a set of Java API for executing SQL statements. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications.
  2. What are drivers available?- a) JDBC-ODBC Bridge driver b) Native API Partly-Java driver c) JDBC-Net Pure Java driver d) Native-Protocol Pure Java driver
  3. What is the difference between JDBC and ODBC?- a) OBDC is for Microsoft and JDBC is for Java applications. b) ODBC can’t be directly used with Java because it uses a C interface. c) ODBC makes use of pointers which have been removed totally from Java. d) ODBC mixes simple and advanced features together and has complex options for simple queries. But JDBC is designed to keep things simple while allowing advanced capabilities when required. e) ODBC requires manual installation of the ODBC driver manager and driver on all client machines. JDBC drivers are written in Java and JDBC code is automatically installable, secure, and portable on all platforms. f) JDBC API is a natural Java interface and is built on ODBC. JDBC retains some of the basic features of ODBC.
  1. 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. A JDBC driver is required to communicate with the particular database management system that is being accessed. SQL statements are sent to the database and the results are given to user. This model is referred to as client/server configuration where user is the client and the machine that has the database is called as the server. Three tier model: A middle tier is introduced in this model. The functions of this model are: a) Collection of SQL statements from the client and handing it over to the database, b) Receiving results from database to the client and c) Maintaining control over accessing and updating of the above.
  2. What are the steps involved for making a connection with a database or how do you connect to a database? a) Loading the driver : To load the driver, Class. forName() method is used. Class. forName(”sun. jdbc. odbc. JdbcOdbcDriver”); When the driver is loaded, it registers itself with the java. sql. DriverManager class as an available database driver. b) Making a connection with database: To open a connection to a given database, DriverManager. getConnection() method is used. Connection con = DriverManager. getConnection (”jdbc:odbc:somedb”, “user”, “password”); c) Executing SQL statements : To execute a SQL query, java. sql. statements class is used. createStatement() method of Connection to obtain a new Statement object. Statement stmt = con. createStatement(); A query that returns data can be executed using the executeQuery() method of Statement. This method executes the statement and returns a java. sql. ResultSet that encapsulates the retrieved data: ResultSet rs = stmt. executeQuery(”SELECT * FROM some table”); d) Process the results : ResultSet returns one row at a time. Next() method of ResultSet object can be called to move to the next row. The getString() and getObject() methods are used for retrieving column values: while(rs. next()) { String event = rs. getString(”event”); Object count = (Integer) rs. getObject(”count”);
  3. 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).

Comments

Post a Comment

Popular Posts

DOT NET Interview Questions with Answers

When not to use Design Patterns?Do not use design patterns in any of the following situations.• When the software being designed would not change with time.• When the requirements of the source code of the application are unique.If any of the above applies in the current software design, there is no need to apply design patterns in the current design and increase unnecessary complexity in the design.When to use Design Patterns?Design Patterns are particularly useful in one of the following scenarios.• When the software application would change in due course of time.• When the application contains source code that involves object creation and event notification.Benefits of Design Patterns:The following are some of the major advantages of using Design Patterns in software development.• Flexibility• Adaptability to change• ReusabilityWhat are Design Patterns?A Design Pattern essentially consists of a problem in a software design and a solution to the same. In Design Patterns each pattern…

Free Java Tutorial from Guru99

FREE JAVA TUTORIAL
Guru99 Goal is to provide Fun and Free Education for ALL.

Guru99 recently create tutorials on JAVA that took 190 hours to create with beautifully annotated screenshots, videos and is very comprehensive.

The course covers

JAVA Basics like Java Virtual Machine (JVM) and Download and Install Guide.
It also introduces Concepts of OOPs, Constructors, Inheritance, Memory Management, Exception Handling and Conditional Loops.
We also touch on advanced topics like Multithreading, Timer and Java Reflection API

Here is the Link: http://www.guru99.com/java-tutorial.html


!! LEARN NOW !!


free java tutorial, guru99, learn java online for free, java classes, java videos, java interview questions and answers, java topics.

Mobile Number Portability in India by Sept 20

Department of Telecom has issued (.pdf) a notification stating that long awaited number portability will finally be available by September 20. The main object of number portability is to be able to retain the same number even after switching between different mobile service providers.  

Mobile Number Portability gives a mobile subscriber the leverage of retaining his/her mobile phone number even after switching between networks. As per Department of Telecom - Mobile Number Portability is to be implemented in Delhi, Mumbai, Maharashtra and Gujarat Service areas of Zone I and Zone 2 includes Kolkata, Tamil Nadu, Chennai, Andhra and Karnataka of within six months of award of license by September 20, 2009, and in the rest of the country by March 20, 2010.

Syniverse Technologies have been licensed for MNP operations in Zone I while MNP Interconnection got licensed for MNP operations in Zone 2.  

TRAI will decide all kinds of mobile number portability tariffs like the transaction fees from…

DesignEvo - A free and easy online logo designer

DesignEvo is easy-to-use online logo design tool with millions of icons, 100+ stylish fonts, 3,000+ practical logo templates and handy editing tools. It can help people easily create appealing and effective logos for their brands, websites, blogs, social media channels, etc.

 It is really awesome and intuitive interface. Easy to design and customize. A person can easily design by selecting a pre-defined logo design and modify it on the fly.

Hardly you need 1 minute to design your new logo with minor modifications.


Its really awesome site. I suggest you to try it out.



You can discover more about DesignEvo here:
https://www.designevo.com

Learn more about Designevo @ YouTube

designevo, free logo design, logo maker, create a logo, easy logo maker, design logo free, free logo, logo designs, logo images

Contact Form

Name

Email *

Message *