Sei sulla pagina 1di 36

JAVA Questions

1. How could Java classes direct program messages to the system console, but
error messages, say to a file?

The class System has a variable out that represents the standard output, and the
variable err that represents the standard error device. By default, they both point
at the system console. This how the standard output could be re-directed:

Stream st =
new Stream (new
FileOutputStream ("techinterviews_com.txt"));
System.setErr(st);
System.setOut(st);

2. What’s the difference between an interface and an abstract class?

An abstract class may contain code in method bodies, which is not allowed in an
interface. With abstract classes, you have to inherit your class from it and Java
does not allow multiple inheritance. On the other hand, you can implement
multiple interfaces in your class.

3. Why would you use a synchronized block vs. synchronized method?

Synchronized blocks place locks for shorter periods than synchronized methods.

4. Explain the usage of the keyword transient?

This keyword indicates that the value of this member variable does not have to be
serialized with the object. When the class will be de-serialized, this variable will
be initialized with a default value of its data type (i.e. zero for integers).

5. How can you force garbage collection?

You can’t force GC, but could request it by calling System.gc(). JVM does not
guarantee that GC will be started immediately.

6. How do you know if an explicit object casting is needed?

If you assign a superclass object to a variable of a subclass’s data type, you need
to do explicit casting. For example:

Object a;Customer b; b = (Customer) a;

When you assign a subclass to a variable having a supeclass type, the casting is
performed automatically.
7. What’s the difference between the methods sleep() and wait()

The code sleep(1000); puts thread aside for exactly one second. The code
wait(1000), causes a wait of up to one second. A thread could stop waiting earlier
if it receives the notify() or notifyAll() call. The method wait() is defined in the
class Object and the method sleep() is defined in the class Thread.

8. Can you write a Java class that could be used both as an applet as well as an
application?

Yes. Add a main() method to the applet.

9. What’s the difference between constructors and other methods?

Constructors must have the same name as the class and can not return a value.
They are only called once while regular methods could be called many times.

10. Can you call one constructor from another if a class has multiple
constructors

Yes. Use this() syntax.

11. Explain the usage of Java packages.

This is a way to organize files when a project consists of multiple modules. It also
helps resolve naming conflicts when different packages have classes with the
same names. Packages access level also allows you to protect data from being
used by the non-authorized classes.

12. If a class is located in a package, what do you need to change in the OS


environment to be able to use it?

You need to add a directory or a jar file that contains the package directories to the
CLASSPATH environment variable. Let’s say a class Employee belongs to a
package com.xyz.hr; and is located in the file c:/dev/com.xyz.hr.Employee.java.
In this case, you’d need to add c:/dev to the variable CLASSPATH. If this class
contains the method main(), you could test it from a command prompt window as
follows:
c:\>java com.xyz.hr.Employee

13. What’s the difference between J2SDK 1.5 and J2SDK 5.0?

There’s no difference, Sun Microsystems just re-branded this version.

14. What would you use to compare two String variables - the operator == or the
method equals()?
I’d use the method equals() to compare the values of the Strings and the = = to
check if two variables point at the same instance of a String object.

15. Does it matter in what order catch statements for FileNotFoundException


and IOExceptipon are written?

A. Yes, it does. The FileNoFoundException is inherited from the IOException.


Exception’s subclasses have to be caught first.

16. Can an inner class declared inside of a method access local variables of this
method?

It’s possible if these variables are final.

17. What can go wrong if you replace && with & in the following code:
18.String a=null;
19.if (a!=null && a.length()>10)
{...}

A single ampersand here would lead to a NullPointerException.

20. What’s the main difference between a Vector and an ArrayList

Java Vector class is internally synchronized and ArrayList is not.

21. When should the method invokeLater()be used?

This method is used to ensure that Swing components are updated through the
event-dispatching thread.

22. How can a subclass call a method or a constructor defined in a superclass?

Use the following syntax: super.myMethod(); To call a constructor of the


superclass, just write super(); in the first line of the subclass’s constructor.

23. What’s the difference between a queue and a stack?

Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule.

24. You can create an abstract class that contains only abstract methods. On the
other hand, you can create an interface that declares the same methods. So
can you use abstract classes instead of interfaces?

Sometimes. But your class may be a descendent of another class and in this case
the interface is your only option.

25. What comes to mind when you hear about a young generation in Java?
Garbage collection.

26. What comes to mind when someone mentions a shallow copy in Java?

Object cloning.

27. If you’re overriding the method equals() of an object, which other method
you might also consider?

hashCode()

28. You are planning to do an indexed search in a list of objects. Which of the
two Java collections should you use: ArrayList or LinkedList?

ArrayList

29. How would you make a copy of an entire Java object with its state?

Have this class implement Cloneable interface and call its method clone().

30. How can you minimize the need of garbage collection and make the memory
use more effective?

Use object pooling and weak object references.

31. There are two classes: A and B. The class B need to inform a class A when
some important event has happened. What Java technique would you use to
implement it?

If these classes are threads I’d consider notify() or notifyAll(). For regular classes
you can use the Observer interface.

32. What access level do you need to specify in the class declaration to ensure
that only classes from the same directory can access it?

You do not need to specify any access level, and Java will use a default package
access level.
SQL Database interview questions

SQL
SQL is an English like language consisting of commands to store, retrieve, maintain &
regulate access to your database.

SQL*Plus
SQL*Plus is an application that recognizes & executes SQL commands & specialized
SQL*Plus commands that can customize reports, provide help & edit facility & maintain
system variables.

NVL
NVL : Null value function converts a null value to a non-null value for the purpose of
evaluating an expression. Numeric Functions accept numeric I/P & return numeric
values. They are MOD, SQRT, ROUND, TRUNC & POWER.

Date Functions
Date Functions are ADD_MONTHS, LAST_DAY, NEXT_DAY, MONTHS_BETWEEN
& SYSDATE.

Character Functions
Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional
functions are GREATEST & LEAST. Group Functions returns results based upon groups
of rows rather than one result per row, use group functions. They are AVG, COUNT,
MAX, MIN & SUM.

TTITLE & BTITLE


TTITLE & BTITLE are commands to control report headings & footers.

COLUMN
COLUMN command define column headings & format data values.

BREAK
BREAK command clarify reports by suppressing repeated values, skipping lines &
allowing for controlled break points.

COMPUTE
command control computations on subsets created by the BREAK command.
SET
SET command changes the system variables affecting the report environment.

SPOOL
SPOOL command creates a print file of the report.

JOIN
JOIN is the form of SELECT command that combines info from two or more tables.
Types of Joins are Simple (Equijoin & Non-Equijoin), Outer & Self join.
Equijoin returns rows from two or more tables joined together based upon a equality
condition in the WHERE clause.
Non-Equijoin returns rows from two or more tables based upon a relationship other than
the equality condition in the WHERE clause.
Outer Join combines two or more tables returning those rows from one table that have no
direct match in the other table.
Self Join joins a table to itself as though it were two separate tables.

Union
Union is the product of two or more tables.

Intersect
Intersect is the product of two tables listing only the matching rows.

Minus
Minus is the product of two tables listing only the non-matching rows.

Correlated Subquery
Correlated Subquery is a subquery that is evaluated once for each row processed by the
parent statement. Parent statement can be Select, Update or Delete. Use CRSQ to answer
multipart questions whose answer depends on the value in each row processed by parent
statement.

Multiple columns
Multiple columns can be returned from a Nested Subquery.

Sequences
Sequences are used for generating sequence numbers without any overhead of locking.
Drawback is that after generating a sequence number if the transaction is rolled back,
then that sequence number is lost.

Synonyms
Synonyms is the alias name for table, views, sequences & procedures and are created for
reasons of Security and Convenience.
Two levels are Public - created by DBA & accessible to all the users. Private - Accessible
to creator only. Advantages are referencing without specifying the owner and Flexibility
to customize a more meaningful naming convention.

Indexes
Indexes are optional structures associated with tables used to speed query execution
and/or guarantee uniqueness. Create an index if there are frequent retrieval of fewer than
10-15% of the rows in a large table and columns are referenced frequently in the WHERE
clause. Implied tradeoff is query speed vs. update speed. Oracle automatically update
indexes. Concatenated index max. is 16 columns.

Data types
Max. columns in a table is 255. Max. Char size is 255, Long is 64K & Number is 38
digits.
Cannot Query on a long column.
Char, Varchar2 Max. size is 2000 & default is 1 byte.
Number(p,s) p is precision range 1 to 38, s is scale -84 to 127.
Long Character data of variable length upto 2GB.
Date Range from Jan 4712 BC to Dec 4712 AD.
Raw Stores Binary data (Graphics Image & Digitized Sound). Max. is 255 bytes.
Mslabel Binary format of an OS label. Used primarily with Trusted Oracle.

Order of SQL statement execution


Where clause, Group By clause, Having clause, Order By clause & Select.

Transaction
Transaction is defined as all changes made to the database between successive commits.

Commit
Commit is an event that attempts to make data in the database identical to the data in the
form. It involves writing or posting data to the database and committing data to the
database. Forms check the validity of the data in fields and records during a commit.
Validity check are uniqueness, consistency and db restrictions.

Posting
Posting is an event that writes Inserts, Updates & Deletes in the forms to the database but
not committing these transactions to the database.

Rollback
Rollback causes work in the current transaction to be undone.

Savepoint
Savepoint is a point within a particular transaction to which you may rollback without
rolling back the entire transaction.

Set Transaction
Set Transaction is to establish properties for the current transaction.
Locking
Locking are mechanisms intended to prevent destructive interaction between users
accessing data. Locks are used to achieve.

Consistency
Consistency : Assures users that the data they are changing or viewing is not changed
until the are thro’ with it.

Integrity
Assures database data and structures reflects all changes made to them in the correct
sequence. Locks ensure data integrity and maximum concurrent access to data. Commit
statement releases all locks. Types of locks are given below.
Data Locks protects data i.e. Table or Row lock.
Dictionary Locks protects the structure of database object i.e. ensures table’s structure
does not change for the duration of the transaction.
Internal Locks & Latches protects the internal database structures. They are automatic.
Exclusive Lock allows queries on locked table but no other activity is allowed.
Share Lock allows concurrent queries but prohibits updates to the locked tables.
Row Share allows concurrent access to the locked table but prohibits for a exclusive table
lock.
Row Exclusive same as Row Share but prohibits locking in shared mode.
Shared Row Exclusive locks the whole table and allows users to look at rows in the table
but prohibit others from locking the table in share or updating them.
Share Update are synonymous with Row Share.

Deadlock
Deadlock is a unique situation in a multi user system that causes two or more users to
wait indefinitely for a locked resource. First user needs a resource locked by the second
user and the second user needs a resource locked by the first user. To avoid dead locks,
avoid using exclusive table lock and if using, use it in the same sequence and use Commit
frequently to release locks.

Mutating Table
Mutating Table is a table that is currently being modified by an Insert, Update or Delete
statement. Constraining Table is a table that a triggering statement might need to read
either directly for a SQL statement or indirectly for a declarative Referential Integrity
constraints. Pseudo Columns behaves like a column in a table but are not actually stored
in the table. E.g. Currval, Nextval, Rowid, Rownum, Level etc.

SQL*Loader
SQL*Loader is a product for moving data in external files into tables in an Oracle
database. To load data from external files into an Oracle database, two types of input
must be provided to SQL*Loader : the data itself and the control file. The control file
describes the data to be loaded. It describes the Names and format of the data files,
Specifications for loading data and the Data to be loaded (optional). Invoking the loader
sqlload username/password controlfilename.
HR Questions
1. What is more important to you: the money or the work? Subscribe
Money is always important, but the work is the most important. There is no better answer.

Latest Answer: I think Money is more important than Work, All are satisfied when get
More Money for Less work, But...
Last Updated By Prasad on June 23, 2007 (Answers: 12) Read / Answer
2. What would your previous supervisor say your strongest point is? Subscribe
There are numerous good possibilities: Loyalty, Energy, Positive attitude, Leadership,
Team player, Expertise, Initiative, Patience, Hard work, Creativity, Problem solver
Latest Answer: Dedication: willingness to go the extra mile to achieve excellence...
Last Updated By Riya on August 25, 2006 (Answers: 2) Read / Answer
3. Tell me about a problem you had with a supervisor? Subscribe
Biggest trap of all. This is a test to see if you will speak ill of your boss. If you fall for it
and tell about a problem with a former boss, you may well below the interview right
there. Stay positi
Latest Answer: Hi,To add up a little humour, sayActually, it was he who was having
problem's. I was just constantly...
Last Updated By Bhaskar on April 25, 2006 (Answers: 2) Read / Answer
4. What has disappointed you about a job? Subscribe
Don't get trivial or negative. Safe areas are few but can include: Not enough of a
challenge. You were laid off in a reduction Company did not win a contract, which would
have given you more responsib
Read / Answer
5. Tell me about your ability to work under pressure? Subscribe
You may say that you thrive under certain types of pressure. Give an example that relates
to the type of position applied for.
Latest Answer: It is one's personal tolerence power to handle the tens condition. To solve
it or say handle it,you ...
Last Updated By ganju on June 08, 2007 (Answers: 5) Read / Answer
6. Do your skills match this job or another job more closely? Subscribe
Probably this one. Do not give fuel to the suspicion that you may want another job more
than this one.
Latest Answer: I would try to utilise my skills according to the job given to me......
Last Updated By kana on April 12, 2006 (Answers: 1) Read / Answer
7. What motivates you to do your best on the job? Subscribe
This is a personal trait that only you can say, but good examples are: Challenge,
Achievement, Recognition
Latest Answer: perfection,confidence,patience are the thing me to motivate on the job...
Last Updated By karthick on May 12, 2006 (Answers: 3) Read / Answer
8. Are you willing to work overtime? Nights? Weekends? Subscribe
This is up to you. Be totally honest. How would you know you were successful on this
job?
Latest Answer: If the project deadlined demand then yes. Do not show that its your
culture to work overnights....
Last Updated By Rahul on January 14,
(Answers: 2) Read / Answer
2007
9. Would you be willing to relocate if required? Subscribe
You should be clear on this with your family prior to the interview if you think there is a
chance it may come up. Do not say yes just to get the job if the real answer is no. This can
create a lot o
Latest Answer: yes of course....i would like to work in a different environment and after
a couple of years i'l...
Last Updated By karthic on July 05, 2007 (Answers: 3) Read / Answer
10. Are you willing to put the interests of the organization ahead of Subscribe
your own?
This is a straight loyalty and dedication question. Do not worry about the deep ethical and
philosophical implications. Just say yes.
Latest Answer: : Yes, but in return I would expect the organization to take care of my
needs as an individual...
Last Updated By Deepali on January 25,
(Answers: 1) Read / Answer
2007
ORACLE Questions
RE: Which one is faster DELETE/TRUNCATE? Why?

Truncate table
------------------
1) Truncate table is DDL and can be run by the owner of the table.
2) Can't Rollback the truncate table command.
3) It release the space and re-set the high water mark in the segment.
4) Selective record deletion is not possible with truncate table . i.e you can not
specifiy where condition in truncate table command.

Delete
--------
1) User with delete permission can delete records from the table.
2) Delete can be rollback.
3) Does not release the occupied space in the segment.
4) We can specifiy selective record deletion in delete i.e. delete from <table_name>
where <condition>

RE: difference between oracle 8i and 9i ?

There are many differences between oracle 8i and oracle 9i

(1) In oracle 8i default tablespace is dictonary managed while in 9i it is locally managed.

(2)Oracle 9i can support 512 PetaByte of data.

(3)Oracle can supprt 10,000 concurrent users.

(4)oracle 9i provides auto undo segment management.

and there a lot difference in oracle 9i and 8i as 9i Support RAC Concept.


1. Undo Retention

2. Incremental level backup using export and import is not there in Oracle 9i

3. Lot of simplified scripts for RMAN backup and Recovery when compared to Oracle 8i

4. In Oracle 9i Rollback segments (undo) is managed automatically by Oracle.

: what is the difference between primary key, unique key, sorrougate key?

To answer your question its sufficient enough to understand their definitions.

Primary Key: A column in a table whose values uniquely identify the rows in the
table. A primary key value cannot be NULL.

Unique Key: Unique Keys are used to uniquely identify each row in an Oracle table.
There can be one and only one row for each unique key value.

Surrogate Key: A system generated key with no business value. Usually implemented
with database generated sequences.

Primay Key Unique key

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

1.There is only one there may be more than 1


Primary key for Unique Key in table
1 table

2.It can contain It Can contain Null Value


Null value

RE: What is stucture of Database

Oracle database usually contains one database and a single instance. But, Oracle 9i,
10g RAC (Real Application Clusters) can have multiple instances to interact with a single
database for high availability.

Instance is non-persistent, memory based background processes and structures.

Database is persistent, disk based, data and control files


what is normalization? what is the advantage of normalization (briefly)

The process of separating data into distinct, unique sets is called normalization. This
is implemented to imorove the performance of the RDBMS, such as reduceces
redunbdancy of data and data inconsistency.

Normalization is the process of removing redundant data from your tables in order to
improve storage efficiency, data integrity and scalability

Database normalization is a series of steps followed to obtain a database design that


allows for consistent storage and efficient access of data in a relational database
.These steps reduce data redundancy and the risk of data becoming inconsistent

Normalization is the process used to reduce the unnecessary repetetion of data i.e,
redundant data.It is performed on the data which is redundant and makes the data in a
normalized format.It is of step-by-step processIstNotmal FormIIndNormal
formIIIrdNormalformIVth Normalform or BoyceCodd Normal formBy perofmring
this we will get the data in the Normalized formati.,e from DBMS to RDBMS.

Normalization is the process of organizing data in a database. This includes creating


tables and establishing relationships between those tables according to rules designed
both to protect the data and to make the database more flexible by eliminating two
factors: redundancy and inconsistent dependency.
Redundant data wastes disk space and creates maintenance problems. If data that exists in
more than one place must be changed, the data must be changed in exactly the same way
in all locations. A customer address change is much easier to implement if that data is
stored only in the Customers table and nowhere else in the database.
What is an "inconsistent dependency"? While it is intuitive for a user to look in the
Customers table for the address of a particular customer, it may not make sense to look
there for the salary of the employee who calls on that customer. The employee's salary is
related to, or dependent on, the employee and thus should be moved to the Employees
table. Inconsistent dependencies can make data difficult to access; the path to find the
data may be missing or broken.
There are a few rules for database normalization. Each rule is called a "normal form." If
the first rule is observed, the database is said to be in "first normal form." If the first three
rules are observed, the database is considered to be in "third normal form." Although
other levels of normalization are possible, third normal form is considered the highest
level necessary for most applications.
As with many formal rules and specifications, real world scenarios do not always allow
for perfect compliance. In general, normalization requires additional tables and some
customers find this cumbersome. If you decide to violate one of the first three rules of
normalization, make sure that your application anticipates any problems that could occur,
such as redundant data and inconsistent dependencies.
NOTE: The following descriptions include examples.

First Normal Form

• Eliminate repeating groups in individual tables.


• Create a separate table for each set of related data.
• Identify each set of related data with a primary key.

Do not use multiple fields in a single table to store similar data. For example, to track an
inventory item that may come from two possible sources, an inventory record may
contain fields for Vendor Code 1 and Vendor Code 2.
But what happens when you add a third vendor? Adding a field is not the answer; it
requires program and table modifications and does not smoothly accommodate a dynamic
number of vendors. Instead, place all vendor information in a separate table called
Vendors, then link inventory to vendors with an item number key, or vendors to inventory
with a vendor code key.

Second Normal Form

• Create separate tables for sets of values that apply to multiple records.
• Relate these tables with a foreign key.

Records should not depend on anything other than a table's primary key (a compound
key, if necessary). For example, consider a customer's address in an accounting system.
The address is needed by the Customers table, but also by the Orders, Shipping, Invoices,
Accounts Receivable, and Collections tables. Instead of storing the customer's address as
a separate entry in each of these tables, store it in one place, either in the Customers table
or in a separate Addresses table.

Third Normal Form

• Eliminate fields that do not depend on the key.

Values in a record that are not part of that record's key do not belong in the table. In
general, any time the contents of a group of fields may apply to more than a single record
in the table, consider placing those fields in a separate table.
For example, in an Employee Recruitment table, a candidate's university name and
address may be included. But you need a complete list of universities for group mailings.
If university information is stored in the Candidates table, there is no way to list
universities with no current candidates. Create a separate Universities table and link it to
the Candidates table with a university code key.
EXCEPTION: Adhering to the third normal form, while theoretically desirable, is not
always practical. If you have a Customers table and you want to eliminate all possible
interfield dependencies, you must create separate tables for cities, ZIP codes, sales
representatives, customer classes, and any other factor that may be duplicated in multiple
records. In theory, normalization is worth pursuing; however, many small tables may
degrade performance or exceed open file and memory capacities.
It may be more feasible to apply third normal form only to data that changes frequently.
If some dependent fields remain, design your application to require the user to verify all
related fields when any one is changed.

Other Normalization Forms

Fourth normal form, also called Boyce Codd Normal Form (BCNF), and fifth normal
form do exist, but are rarely considered in practical design. Disregarding these rules may
result in less than perfect database design, but should not affect functionality.

**********************************
Examples of Normalized Tables
********************************** Normalization Examples: Unnormalized
table: Student# Advisor Adv-Room Class1 Class2 Class3
------------------------------------------------------- 1022
Jones 412 101-07 143-01 159-02 4123 Smith
216 201-01 211-02 214-01

1. First Normal Form: NO REPEATING GROUPS


Tables should have only two dimensions. Since one student has several classes,
these classes should be listed in a separate table. Fields Class1, Class2, & Class3
in the above record are indications of design trouble.
Spreadsheets often use the third dimension, but tables should not. Another way to
look at this problem: with a one-to-many relationship, do not put the one side and
the many side in the same table. Instead, create another table in first normal form
by eliminating the repeating group (Class#), as shown below:

Student# Advisor Adv-Room Class#


--------------------------------------- 1022 Jones
412 101-07 1022 Jones 412 143-01
1022 Jones 412 159-02 4123 Smith
216 201-01 4123 Smith 216 211-02
4123 Smith 216 214-01

2. Second Normal Form: ELIMINATE REDUNDANT DATA


Note the multiple Class# values for each Student# value in the above table. Class#
is not functionally dependent on Student# (primary key), so this relationship is not
in second normal form.
The following two tables demonstrate second normal form:

Students: Student# Advisor Adv-Room


------------------------------ 1022 Jones
412 4123 Smith 216 Registration:
Student# Class# ------------------
1022 101-07 1022 143-01
1022 159-02 4123 201-01
4123 211-02 4123 214-01
3. Third Normal Form: ELIMINATE DATA NOT DEPENDENT ON KEY
In the last example, Adv-Room (the advisor's office number) is functionally
dependent on the Advisor attribute. The solution is to move that attribute from the
Students table to the Faculty table, as shown below:

Students: Student# Advisor


------------------- 1022 Jones
4123 Smith Faculty: Name Room Dept
-------------------- Jones 412 42
Smith 216 42
RE: In Oracle varchar2 takes dynamic space for storage...

The mejor defference between varchar2 and char is fixed length and variable length .
varchar2 have varible length mean if we declare as 20 space and its use only 5 space the
memory asigne only 5 . but in char takes daclare space while use any number space less
than declare .

char is used if we know that the length wont exceed the specified range while varchar is
used for varying range.

If we want any string not exceeding 6, we use char(6),because we can put a constraint if
someone is trying to enter more or less than 6.

When we export external data then we used fixed lenght of record this is possible by char
or second reson is whenever we use varchar it stores its width which occupies memory.
so here two reson is sufficient for char.

Third reason is performance .

char is of fied length search operation becomes faster since oracle engine has to look for
predetermined length of characters.

what is the diffrence between and constraints and triggers

Constraints are used to maintain the integrity and atomicity of database .in other words
it can be said they are used to prevent invalid data entry . the main 5 constraints are
NOT NULL,PRIMARY KEY,FOREIGN KEY,UNIQUE KEY and CHECK

Triggers are bascically stored procedures which automaticallly fired when any
insert,update or delete is issued on table.

Another most imp. deff. is that trigger effected only those row after which trigger applied
but constraint effected all row of table .

Triggers are used to carry out tasks which cant be done using constraints.
For eg:-A change in the "sal" column of a table should change the "tax" column in
another table.This cant be done using constraints.It has to be done using triggers.Thats
where the importance of triggers lie.

RE: What is the difference between "NULL in C" and "NU...

The NULL in C treated as Zero or void. but in SQL NULL value is Non or blank
represented it can't manuplated.

NULL in SQL in an unknown value. It neither zero nor any valid value. It cannot be
mapulated, but it can only be compared.

With reference from the Oracle book,NULL is a undetermined value and will lead to
infinite process (loop). NULL must be handled carefully to avoid ambiguity.To
understand the difference, ZERO is a numeric value and BLANK is a special
character.All the best!!!

RE: What is difference between varchar and varchar2

Varchar and Varchar2 are both same except for varchar2 supports upto 2000 char

hi... in oracle name varchar(10)-in this declaration it allocate 10 spaces in memory.if


suppose ur using 4 charecter the extra space wasted. name varcher2(10)-in this
declaration the extra space used by other operations automatically.

Both varchar and varchar2 are same which is of variable length characters but

in varchar maximum chars are 2000 and in later one is 4000 bytes.

There are how many maximum no of colimns in atabl...

Final Answer : 1000 columns/table.

E: What is the Difference between Replace and Transla...

Both Replace and Translate are single row functions in Oracle 9i.

The Replace Function replaces single character with multiple characters.

But in Translate Function replaces sinlge character with sinlge character only.
what is the difference between rownum,rowid

Rownum is just the serial No of your output while Rowid is automatically


generated unique id of a row an it is generated at the time of insertion of row.

Rownum is numeric and rowid is 16 bit hexadecimal no.

rowid has a physical significance i.e you can read a row if you know rowid. It is complete
physical address of a row.

While rownum is temporary serial number allocated to each returned row during query
execution.

RE: What is the difference between cold backup and hot...

Cold Backup- We can take the Backup while DB(eg. Oracle) is down.
Hot Backup-We can take the Backup while DB(eg. Oracle) is running.
Cold backup is a physical backup. During a cold backup the database is closed and
not available to users. All files of the database are copied (image copy). The
datafiles do not change during the copy so the database is in sync upon restore.
Used when:Service level allows for some down time for backup
Hot backup is a physical backup. In a hot backup the database remains open and
available to users. All files of the database are copied (image copy). There may be
changes to the database as the copy is made and so all log files of changes being
made during the backup must be saved too. Upon a restore, the changes in the log
files are reapplied to bring the database in sync. Used when:A full backup of a
database is needed
Service level allows no down time for the backup.
JAVA Questions
How to define an Abstract class?
Answer: A class containing abstract method is called Abstract class. An Abstract class
can't be instantiated.
Example of Abstract class:
abstract class testAbstractClass {
protected String myString;
public String getMyString() {
return myString;
}
public abstract string anyAbstractFunction();
}

Question: How to define an Interface?


Answer: In Java Interface defines the methods but does not implement them. Interface
can include constants. A class that implements the interfaces is bound to implement all
the methods defined in Interface.
Emaple of Interface:

public interface sampleInterface {


public void functionOne();

public long CONSTANT_ONE = 1000;


}

Question: Explain the user defined Exceptions?


Answer: User defined Exceptions are the separate Exception classes defined by the user
for specific purposed. An user defined can created by simply sub-classing it to the
Exception class. This allows custom exceptions to be generated (using throw) and caught
in the same way as normal exceptions.
Example:
class myCustomException extends Exception {
// The class simply has to exist to be an exception
}

Question: Explain the new Features of JDBC 2.0 Core API?


Answer: The JDBC 2.0 API includes the complete JDBC API, which includes both core
and Optional Package API, and provides inductrial-strength database computing
capabilities.
New Features in JDBC 2.0 Core API:

• Scrollable result sets- using new methods in the ResultSet interface allows
programmatically move the to particular row or to a position relative to its current
position
• JDBC 2.0 Core API provides the Batch Updates functionality to the java
applications.
• Java applications can now use the ResultSet.updateXXX methods.
• New data types - interfaces mapping the SQL3 data types
• Custom mapping of user-defined types (UTDs)
• Miscellaneous features, including performance hints, the use of character streams,
full precision for java.math.BigDecimal values, additional security, and support
for time zones in date, time, and timestamp values.

Question: Explain garbage collection?


Answer: Garbage collection is one of the most important feature of Java. Garbage
collection is also called automatic memory management as JVM automatically removes
the unused variables/objects (value is null) from the memory. User program cann't
directly free the object from memory, instead it is the job of the garbage collector to
automatically free the objects that are no longer referenced by a program. 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. In Java, it is
good idea to explicitly assign null into a variable when no more in use. I Java on calling
System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no
guarantee when all the objects will garbage collected.

Question: How you can force the garbage collection?


Answer: Garbage collection automatic process and can't be forced.
Question: What is OOPS?
Answer: OOP is the common abbreviation for Object-Oriented Programming.

Question: Describe the principles of OOPS.


Answer: There are three main principals of oops which are called Polymorphism,
Inheritance and Encapsulation.

Question: Explain the Encapsulation principle.


Answer: Encapsulation is a process of binding or wrapping the data and the codes that
operates on the data into a single entity. This keeps the data safe from outside interface
and misuse. One way to think about encapsulation is as a protective wrapper that prevents
code and data from being arbitrarily accessed by other code defined outside the wrapper.

Question: Explain the Inheritance principle.


Answer: Inheritance is the process by which one object acquires the properties of another
object.

Question: Explain the Polymorphism principle.


Answer: The meaning of Polymorphism is something like one name many forms.
Polymorphism enables one entity to be used as as general category for different types of
actions. The specific action is determined by the exact nature of the situation. The
concept of polymorphism can be explained as "one interface, multiple methods".

Question: Explain the different forms of Polymorphism.


Answer: From a practical programming viewpoint, polymorphism exists in three distinct
forms in Java:

• Method overloading
• Method overriding through inheritance
• Method overriding through the Java interface

Question: What are Access Specifiers available in Java?


Answer: Access specifiers are keywords that determines the type of access to the
member of a class. These are:

• Public
• Protected
• Private
• Defaults

What are the contents of web module?


Answer: A web module may contain:
a) JSP files
b) Java classes
c) gif and html files and
d) web component deployment descriptors

What is the difference between Session Bean and Entity Bean?


Answer:
Session Bean: Session is one of the EJBs and it represents a single client inside the
Application Server. Stateless session is easy to develop and its efficient. As compare to
entity beans session beans require few server resources.

A session bean is similar to an interactive session and is not shared; it can have only one
client, in the same way that an interactive session can have only one user. A session bean
is not persistent and it is destroyed once the session terminates.

Entity Bean: An entity bean represents persistent global data from the database. Entity
beans data are stored into database.
What are types of J2EE clients?
Answer: J2EE clients are the software that access the services components installed on
the J2EE container. Following are the J2EE clients:
a) Applets
b) Java-Web Start clients
c) Wireless clients
d) Web applications

What are the services provided by a container?


Answer: The services provided by container are as follows:
a) Transaction management for the bean
b) Security for the bean
c) Persistence of the bean
d) Remote access to the bean
e) Lifecycle management of the bean
f) Database-connection pooling
g) Instance pooling for the bean
What is Deployment Descriptor?
Answer: A deployment descriptor is simply an XML(Extensible Markup Language) file
with the extension of .xml. Deployment descriptor describes the component deployment
settings. Application servers reads the deployment descriptor to deploy the components
contained in the deployment unit. For example ejb-jar.xml file is used to describe the
setting of the EJBs.
What is difference between Java Bean and Enterprise Java Bean?
Answer: Java Bean as is a plain java class with member variables and getter setter
methods. Java Beans are defined under JavaBeans specification as Java-Based software
component model which includes the features like introspection, customization, events,
properties and persistence.
Enterprise JavaBeans or EJBs for short are Java-based software components that comply
with Java's EJB specification. EJBs are delpoyed on the EJB container and executes in
the EJB container. EJB is not that simple, it is used for building distributed applications.
Examples of EJB are Session Bean, Entity Bean and Message Driven Bean. EJB is used
for server side programming whereas java bean is a client side. Bean is only development
but the EJB is developed and then deploy on EJB Container.
What are the call back methods in Session bean?
Answer: Callback methods are called by the container to notify the important events to
the beans in its life cycle. The callback methods are defined in the javax.ejb.EntityBean
interface.The callback methods example are ejbCreate(), ejbPassivate(), and
ejbActivate().
Can a private method of a superclass be declared within a subclass?
Answer: Sure. A private field or method or inner class belongs to its declared class and
hides from its subclasses. There is no way for private stuff to have a runtime overloading
or overriding (polymorphism) features.

Why Java does not support multiple inheritence ?


Answer: Java DOES support multiple inheritance via interface implementation.

Question:What is the difference between final, finally and finalize?


Answer: o final - declare constant
o finally - handles exception
o finalize - helps in garbage collection

Question: Where and how can you use a private constructor.


Answer: Private constructor can be used if you do not want any other class to instanstiate
the object , the instantiation is done from a static public method, this method is used
when dealing with the factory method pattern when the designer wants only one
controller (fatory method ) to create the object.

Question: In System.out.println(),what is System,out and println,pls explain?


Answer: System is a predefined final class,out is a PrintStream object and println is a
built-in overloaded method in the out object.

Question: What is meant by "Abstract Interface"?


Answer: First, an interface is abstract. That means you cannot have any implementation
in an interface. All the methods declared in an interface are abstract methods or
signatures of the methods.
What is the difference between Swing and AWT components?
Answer: AWT components are heavy-weight, whereas Swing components are
lightweight. Heavy weight components 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.

Question: Why Java does not support pointers?


Answer: Because pointers are unsafe. Java uses reference types to hide pointers and
programmers feel easier to deal with reference types without pointers. This is why Java
and C# shine.

hat is a platform?
Answer: A platform is the hardware or software environment in which a program runs.
Most platforms can be described as a combination of the operating system and hardware,
like Windows 2000/XP, Linux, Solaris, and MacOS.

What is the Java API?


Answer: The Java API is a large collection of ready-made software components that
provide many useful capabilities, such as graphical user interface (GUI) widgets.

Question: What is the package?


Answer: The package is a Java namespace or part of Java libraries. The Java API is
grouped into libraries of related classes and interfaces; these libraries are known as
packages.

Question: What is native code?


Answer: The native code is code that after you compile it, the compiled code runs on a
specific hardware platform.

What is the serialization?


Answer: The serialization is a kind of mechanism that makes a class or a bean
persistence by having its properties or fields and state information saved and restored to
and from storage.

Question: How to make a class or a bean serializable?


Answer: By implementing either the java.io.Serializable interface, or the
java.io.Externalizable interface. As long as one class in a class's inheritance hierarchy
implements Serializable or Externalizable, that class is serializable.

How many methods in the Serializable interface?


Answer:There is no method in the Serializable interface. The Serializable interface acts
as a marker, telling the object serialization tools that your class is serializable.
Question: . How many methods in the Externalizable interface?
Answer: There are two methods in the Externalizable interface. You have to implement
these two methods in order to make your class externalizable. These two methods are
readExternal() and writeExternal().

Question: What is the difference between Serializalble and Externalizable interface?


Answer: When you use Serializable interface, your class is serialized automatically by
default. But you can override writeObject() and readObject() two methods to control
more complex object serailization process. When you use Externalizable interface, you
have a complete control over your class's serialization process.

Question: What is a transient variable?


Answer: A transient variable is a variable that may not be serialized. If you don't want
some field to be serialized, you can mark that field transient or static.

Question: Which containers use a border layout as their default layout?


Answer: The Window, Frame and Dialog classes use a border layout as their default
layout.

What is synchronization and why is it important?


Answer: 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?


Answer: 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?
Answer: 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.

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


Answer: The setLayout() method is used to specify a container's layout.

Question: Which containers use a FlowLayout as their default layout?


Answer: The Panel and Applet classes use the FlowLayout as their default layout.

Question: What is thread?


Answer: A thread is an independent path of execution in a system.
Question: What is multithreading?
Answer: Multithreading means various threads that run in a system.

Question: How does multithreading take place on a computer with a single CPU?
Answer: 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.

How to create multithread in a program?


Answer: You have two ways to do so. First, making your class "extends" Thread class.
Second, making your class "implements" Runnable interface. Put jobs in a run() method
and call start() method to start the thread.

Question: Can Java object be locked down for exclusive use by a given thread?
Answer: Yes. You can lock an object by putting it in a "synchronized" block. The locked
object is inaccessible to any thread other than the one that explicitly claimed it

Question: Can each Java object keep track of all the threads that want to exclusively
access to it?
Answer: Yes

Question: What state does a thread enter when it terminates its processing?
Answer: When a thread terminates its processing, it enters the dead state.

Question: What invokes a thread's run() method?


Answer: After a thread is started, via its start() method of the Thread class, the JVM
invokes the thread's run() method when the thread is initially executed.

Question: What is the purpose of the wait(), notify(), and notifyAll() methods?
Answer: The wait(),notify(), and notifyAll() methods are used to provide an efficient
way for threads to communicate each other.

Question: What are the high-level thread states?


Answer: The high-level thread states are ready, running, waiting, and dead.

Question: What is the Collections API?


Answer: The Collections API is a set of classes and interfaces that support operations on
collections of objects.

Question: What is the List interface?


Answer: The List interface provides support for ordered collections of objects.
Question: How does Java handle integer overflows and underflows?
Answer: 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?


Answer: 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.

Question: If a method is declared as protected, where may the method be accessed?


Answer: 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.

Is sizeof a keyword?
Answer: The sizeof operator is not a keyword.

How can you write a loop indefinitely?


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

Question: . Can an anonymous class be declared as implementing an interface and


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

Question: What is the purpose of finalization?


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

Question: Which class is the superclass for every class.


Answer: Object.

Question: What is the difference between the Boolean & operator and the && operator?
Answer: 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 purpose of the System class?
Answer: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?


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

Question: What is the Locale class?


Answer: The Locale class is used to tailor program output to the conventions of a
particular geographic, political, or cultural region.

Question: What must a class do to implement an interface?


Answer: It must provide all of the methods in the interface and identify the interface in
its implements clause.

Question: What is an abstract method?


Answer: An abstract method is a method whose implementation is deferred to a subclass.
Or, a method that has no implementation (an interface of a method).

Question: What is a static method?


Answer: A static method is a method that belongs to the class rather than any object of
the class and doesn't apply to an object or even require that any objects of the class have
been instantiated.

Question: What is a protected method?


Answer: A protected method is a method that can be accessed by any method in its
package and inherited by any subclass of its class.

Question: What is the difference between a static and a non-static inner class?
Answer: 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.

Which package has light weight components?


Answer: javax.Swing package. All components in Swing, except JApplet, JDialog,
JFrame and JWindow are lightweight components.

Question: What are peerless components?


Answer: The peerless components are called light weight components.

What is the difference between throw and throws keywords?


Answer: The throw keyword denotes a statement that causes an exception to be initiated.
It takes the Exception object to be thrown as argument. The exception will be caught by
an immediately encompassing try-catch construction or propagated further up the calling
hierarchy. The throws keyword is a modifier of a method that designates that exceptions
may come out of the mehtod, either by virtue of the method throwing the exception itself
or because it fails to catch such exceptions that a method it calls may throw.

Question: If a class is declared without any access modifiers, where may the class be
accessed?
Answer: 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.

Does a class inherit the constructors of its superclass?


Answer: A class does not inherit constructors from any of its superclasses.

Question: Name primitive Java types.


Answer: The primitive types are byte, char, short, int, long, float, double, and boolean.

What is the difference between static and non-static variables?


Answer: 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.

Question: What is the difference between the paint() and repaint() methods?
Answer: 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 restrictions are placed on method overloading?


Answer: Two methods may not have the same name and argument list but different
return types.

Question: What restrictions are placed on method overriding?


Answer: 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.

Question: What is casting?


Answer: 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.

Question: Name Container classes.


Answer: Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane
How are this() and super() used with constructors?
Answer: this() is used to invoke a constructor of the same class. super() is used to invoke
a superclass constructor.

What is Serialization and deserialization?


Answer: Serialization is the process of writing the state of an object to a byte stream.
Deserialization is the process of restoring these objects.

Question: what is tunnelling?


Answer: 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

What is polymorphism?
Answer: Polymorphism allows methods to be written that needn't be concerned about the
specifics of the objects they will be applied to. That is, the method can be specified at a
higher level of abstraction and can be counted on to work even on objects of yet
unconceived classes.

What is the difference between interface and abstract class?


Answer:

o interface contains methods that must be abstract; abstract class may contain concrete
methods.

o interface contains variables that must be static and final; abstract class may contain
non-final and final variables.

o members in an interface are public by default, abstract class may contain non-public
members.

o interface is used to "implements"; whereas abstract class is used to "extends".

o interface can be used to achieve multiple inheritance; abstract class can be used as a
single inheritance.

o interface can "extends" another interface, abstract class can "extends" another class and
"implements" multiple interfaces.

o interface is absolutely abstract; abstract class can be invoked if a main() exists.

o interface is more flexible than abstract class because one class can only "extends" one
super class, but "implements" multiple interfaces.

o If given a choice, use interface instead of abstract class.


What are the primitive types in Java

Type Size Value


__________________________
boolean 1 bit true/false
char 2 Bytes Unicode (Extended ASCII)
byte 1 Byte
short 2 Bytes
int 4 Bytes
long 8 Bytes
float 4 Bytes
double 8 Bytes

How do you declare constant values in java

A variable can be made constant only with the help of a final keyword. If you want to
make it to be accessible from other classes then you need static.

By declaring it with static final.

How all can you free memory

With the help of finalize() method.

f a programmer really wants to explicitly request a garbage collection at some point,


System.gc() or Runtime.gc() can be invoked, which will fire off a garbage collection at
that time.

What are the different kinds of exceptions? How do you catch a Runtime exception

There are 2 types of exceptions.


1. Checked exception
2. Unchecked exception.

Checked exception is catched at the compile time while unchecked exception is checked
at run time.

RE: What is EJB

Hi,
Enterprise Java bean is a server side component.
it contains business logic and no system level programming and services like
transactions,threading,persistence and security as EJB server provide all these for EJB
component.
EJB component is inherently transactional,scalable and secure.
it is wire-protocol neutral,any protocol can be used like IIOP,HTTP etc.

How is serialization implemented in Java

serialization is implemented by java.lang.seriaizable interface it does not have any


methods so it is tagged interface.

it means transferring object in to the byte form for maintaing persistance within object.
restoring the object is done by deseralization.

What are the differences between AWT and Swing

AWT - Heavy weight component. Every graphical units it will invoke native methods.
SWING - Light weight component. It doesn't invoke native methods.

What are the differences between EJB and Java beans

hi

the main difference is Ejb componenets are distributed which means develop once and
run anywhere.

java beans are not distributed. which means the beans cannot be shared .

What are STRUTS

Struts is a web development framework developed by Apache. It is based on MVC


architecture. In Struts, JSP represents view, ActionServlet represents controller and
Action represents model.

Explain Servlet and JSP life cycle

JSP Lifecycle:

Translation Phase: JSP Page will be converted to Servlet.

Compilation Phase: The resulting servlet is compiled.

Instantiate and loading Phase: Instance will be created for the servlet ands it will be
loaded to memory.
Call jspinit():Perform Initialization process.

Call _jspService(): this will be called upon each request.

Call jspDestroy(): the instance will be destroyed when not needed any more.

Servlet Life Cycle:

Call init(): servlet will be initialized using web.xml

Call service(): this will be called upon each request which in turn calls doXXX()
methods.

call destroy(): called when the servlet object is no longer needed.

Explain the keywords - native, transient, volatil...

native:when you want to get functionality from particular language like c/c++ native is
used

Transient : it is state of which value doesnt persist

volatile : is an indication to the compiler that the value may be changed by the program
some where else

final: can be used for variable,method and for class. final variables acts as constant. final
methods can not be overridden. final class can not have sub class.

Differences between HashList and HashMap, Set an...

HashList is a data structure storing objects in a hash table and a list.it is a combination of
hashmap and doubly linked list. acess will be faster. HashMap is hash table
implementation of map interface it is same as HashTable except that it is unsynchronized
and allow null values. List is an ordered collection and it allow nulls and duplicates in
it. positional acess is possible. Set is a collection that
doesn't allow duplicates, it may allow at most one null element. same as our
mathematical set.

What are the differences between C++ and Java


Java interprets codes, codes written in Java are portable between platforms, but C++
compiles codes, codes written in C++ are MUCH faster.

ow can you do multiple inheritance in Java

hi,

To achieve multiple Inheritance in java we must use Interface.

What is data encapsulation? What does it buy you

encapsulation mean data hiding.data correspond to varibles and methods of the class.
Data hiding mean: when u make different objects of the same class. The data stored in
one object is unaware of the data for other object of the same class. In, this way it gives
secure data.

What is MVC architecture

MVC is an approach for developing interactive applications ie it results in events


through user interaction.MVC stands for Model View Controller.Model is responsible for
holding the application state,view is for displaying the current model and controller
handles the events.

What are the differences between ArrayList and a Vector

1) Arraylist is not synchronized while vector is.


2. Arraylist has no default size while vector has a default size of 10.

Note: Methods in Vector are synchronised which means they are thread-safe and thus
preclude access to the Vector elements by concurrent threads.Bu this imposes additional
overhead on the JVM as it has to acquire and release locks on the vector objects under
consideration.

This is not possible in ArrayList since those methods are not synchronised and hence are
faster in performance.

Use Vector only if it will be accessed by multiple threads at a time else ArrayList is
always better.
In ArrayList we can store similar data types
but in Vectror we can store different types of data.

How does serialization work


serialization means writing object to secondary storage device

lets write one as follows.

class a{

String s;

a(){

s="hi";

now

create objectoutputstream object and give it to fileoutputstream with file name say "a.ser"
(use writeObject() method)

if u check, the object state is written in this file.

now create object Inputstream object and give it to fileinputstream with file same name
"a.ser"(use readObject() method)

same object will be sent from device to console.

chow.

How would you keep track of a session

use session varaible accross application

String vijay=request.getParameter("vijay");

HttpSession createobject name as hs

HttpSesssion hs=request.getSession("true");

this create session object

then call

object.setAttribute("value which we will retrive later",value);


means

hs.setAttribute("sessionobject",vijay);

now on second form

we call as

String name=(String)request.getAttribute("sessionobject");

out.println("name");

in this way we can maintain session with diffrent

isNew() check wether session is new

while invalidating use session.invalidate()

In servlets, session can be tracked using


a) URL rewriting
b) Hiddin FormField
c) cookies
and
d) HttpSession API

In EJB to maintain session go for stateful session beans.

Session tracking is a mechanism that servlets use to maintain state about a series of
requests from the same user (that is, requests originating from the same browser) across
some period of time.

Sessions are shared among the servlets accessed by a client. This is convenient for
applications made up of multiple servlets. For example, Duke's Bookstore uses session

Potrebbero piacerti anche