IT Community - Software Programming, Web Development and Technical Support

Java/J2EE interview Questions

This is a discussion on Java/J2EE interview Questions within the Interview Questions & Answers and Tips forums, part of the DiscussWeb IT Curriculum category; Hey guys, Let us discuss Java/J2EE interview Question... What is JVM (Java Virtual Machine)? Twist: - What are Java Byte ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > DiscussWeb IT Curriculum > Interview Questions & Answers and Tips

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 08-21-2007, 06:53 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Java/J2EE interview Questions

Hey guys,

Let us discuss Java/J2EE interview Question...

What is JVM (Java Virtual Machine)?

Twist: - What are Java Byte Codes?

JVM stands for Java Virtual Machine. It’s an abstract computer or virtual computer whichruns the compiled java programs. Actually JVM is a software implementation which standson the top of the real hardware platform and operating system. It provides abstractionbetween the compiled java program and the hardware and operating system.

So the compiled program does not have to worry about what hardware and operatingsystem he has to run in, it’s all handled by the JVM and thus attaining portability. All Javaprograms are compiled in to bytecodes. JVM can only understand and execute Javabytecodes. You can visualize Java bytecodes as machine language for JVM. Java compilertakes the .java files and compiles it to a “bytecode” file with .class file extension. Compilergenerates one class file for one source file.
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 08-21-2007, 08:26 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Re: Java/J2EE interview Questions

what is the difference between StringBuilder and StringBuffer class?

It is very much similar to StringBuffer except for one difference: it is not synchronized,which means that it is not thread-safe. The advantage of StringBuilder is good performance.In case of multithreading, you must use StringBuffer rather than StringBuilder.
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 08-21-2007, 08:28 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Re: Java/J2EE interview Questions

hey guys,


What are the situations you will need a constructor to be private?

Below are some of the situations when you will need a constructor to be private:-

To implement singleton pattern. That means only one instance of the object need tobe running.

When classes contain static methods. It makes sense that no object of the class needto be created.

If classes have only constants.
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 08-21-2007, 08:30 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Re: Java/J2EE interview Questions

hey,

Define casting? What are the different types of Casting?

Changing the type of the value from one type to other is termed as casting. For instancelook at the below code snippet in which we are trying to cast integer value to double datatype.

int i;
double d;
i = 10;
d = i; // we are trying to assign a int value to double

There are two types of casting explicit and implicit. To explicitly cast an expression prefixthe expression with type name as shown in the code snippet below.


Button mybtn = (Button) (myVector.elementAt(9));

In some situations JAVA runtime changes the type of an expression with out performinga cast. For instance in the below code snippet my inventory object is type casted andstored as type Object.

myVectorSales.add(objInventory);
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 08-21-2007, 08:35 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Re: Java/J2EE interview Questions

hey guys,

Why do we use collections when we had traditional ways forcollection?

Before the collection framework JAVA provided ad hoc classes such as Dictionary, Vector,Stack and Properties to store and manipulate group of objects. Following are the mainreason why collection framework is more desirable than the traditional JAVA collectionobjects:-

√Traditional objects did not have the unifying theme. The way you access VECTORis different from Properties. Due to this ADHOC approach software is not easilyextendable and adaptable. One of the unifying themes in the new JAVA collection isthe iterator interface. It gives a unifying way for looping through JAVA collections.

√Ready made algorithms are one of the important features of the JAVA collection.Algorithms operate on collections and are defined as static methods within theCollections class. Thus, they are available for all collections. Each collection classneed not implement its own versions. The algorithms provide a standard means ofmanipulating collections.

√Implementation of dynamic arrays, linked lists, trees, and hash tables are done inefficient manner. In case of traditional JAVA collection you will need to code allthese implementation by yourself.
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 08-29-2007, 06:16 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default Re: Java/J2EE interview Questions

What is the difference between procedural and object-oriented programs?

a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code.
b) In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old 08-29-2007, 06:18 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default Re: Java/J2EE interview Questions

What are Encapsulation, Inheritance and Polymorphism?
*Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse
*Inheritance is the process by which one object acquires the properties of another object.
* Polymorphism is the feature that allows one interface to be used for general class actions.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8  
Old 08-29-2007, 06:19 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default Re: Java/J2EE interview Questions

What is the difference between Assignment and Initialization?-

Assignment can be done as many times as desired whereas initialization can be done only once.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9  
Old 08-29-2007, 06:20 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default Re: Java/J2EE interview Questions

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. It defines a type of object according to the data the object can hold and the operations the object can perform.
*Constructor is a special kind of method that determines how an object is initialized when created.
*Primitive data types are 8 types and they are: byte, short, int, long, float, double, boolean, char.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10  
Old 08-29-2007, 06:21 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 542
itbarota is on a distinguished road
Default Re: Java/J2EE interview Questions

What is an Object and how do you allocate memory to it?
Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Greetings from Java J2EE web development team tenax_technologies Introductions 1 07-04-2009 11:53 PM
Asp Interview Questions sureshbb ASP and ASP.NET Programming 35 10-29-2008 07:58 PM
CSS Interview Questions And Answers Sabari Interview Questions & Answers and Tips 137 11-25-2007 08:38 PM
HR Interview Questions with Answers Sabari Interview Questions & Answers and Tips 63 11-23-2007 05:13 AM
Interview Questions shiva Interview Questions & Answers and Tips 6 08-24-2007 01:28 AM


All times are GMT -7. The time now is 12:49 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0