G  Tech Lab
About us   |   Contact us   |   Help
Site Search   
G Tech Lab News
G Tech Lab Java Centre
G Tech Lab Provides different interview question and answer, tutorials .
Shortly comming up.... forum for different programming languages.
Read more
INTERVIEW QUESTION

JAVA

Core Java Interview Question
JSP Interview Question
Servlet Interview Question
EJB Interview Question

DATABASE

SQL Interview Question
ORACLE Interview Question
SQL SERVER Interview Question
My SQL Interview Question

1)What is the difference between C++ & Java?

Well as Bjarne Stroustrup says "..despite the syntactic similarities, C++ and Java are very different languages. In many ways, Java seems closer to Smalltalk than to C++..". Here are few I discovered:

  • Java is multithreaded
  • Java has no pointers
  • Java has automatic memory management (garbage collection)
  • Java is platform independent (Stroustrup may differ by saying "Java is a platform"
  • Java has built-in support for comment documentation
  • Java has no operator overloading
  • Java doesnot provide multiple inheritance
  • There are no destructors in Java

2)What is the diffrence between an Abstract class and Interface?

  • Abstract classes may have some executable methods and methods left unimplemented. Interfaces contain no implementation code.
  • A class can implement any number of interfaces, but subclass at most one abstract class.
  • An abstract class can have nonabstract methods. All methods of an interface are abstract.
  • An abstract class can have instance variables. An interface cannot.
  • An abstract class can define constructor. An interface cannot.
  • An abstract class can have any visibility: public, protected, private or none (package). An interface's visibility must be public or none (package).

3)What is a user defined exception?

User-defined exceptions may be implemented by

  • defining a class to respond to the exception and
  • embedding a throw statement in the try block where the exception can occur or declaring that the method throws the exception (to another method where it is handled).

4)What are statements in JAVA ?
Statements are equivalent to sentences in natural languages. A statement forms a complete unit of execution. The following types of expressions can be made into a statement by terminating the expression with a semicolon

  • Assignment expressions
  • Any use of ++ or --
  • Method calls
  • Object creation expressions

5)What is JAR file ?

JavaARchive files are a big glob of Java classes, images, audio, etc., compressed to make one simple, smaller file to ease Applet downloading. Normally when a browser encounters an applet, it goes and downloads all the files, images, audio, used by the Applet separately. This can lead to slower downloads.

6)What is JNI ?

JNI is an acronym of Java Native Interface. Using JNI we can call functions which are written in other languages from Java. Following are its advantages and disadvantages:
Advantages:

  • You want to use your existing library which was previously written in other language.
  • You want to call Windows API function.
  • For the sake of execution speed.
  • You want to call API function of some server product which is in c or c++ from java client.

7)What is serialization ?

Quite simply, object serialization provides a program the ability to read or write a whole object to and from a raw byte stream. It allows Java objects and primitives to be encoded into a byte stream suitable for streaming to some type of network or to a file-system, or more generally, to a transmission medium or storage facility. A seralizable object must implement the Serilizable interface. We use ObjectOutputStream to write this object to a stream and ObjectInputStream to read it from the stream.

8)Why there are some null interface in java ? What does it mean ? Give me some null interfaces in JAVA ?

Null interfaces act as markers..they just tell the compiler that the objects of this class need to be treated differently..some marker interfaces are : Serializable, Remote, Cloneable

9)What are checked and unchecked exceptions?
Checked exceptions are the ones which you expect beforehand to be raised when an exceptional condition occurs and so write your code in a try-catch block to handle that sufficiently. For example: InsuffucientBalanceException which might be raised when money is being withdrawn from a bank account and the account has insufficient balance. Checked exceptions are sub classes of Exception.

Unchecked exceptions are the ones which cannot be handled in the code. These are rather unexpected exceptions like NullPointerException, OutOfMemoryError, DivideByZeroException, typically, programming errors. Unchecked exceptions are subclasses of RunTimeExceptions.


10)Is synchronised a modifier?indentifier?what is it?
It's a modifier. 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.

11)Why java does not have multiple inheritance?
The Java design team strove to make Java:

  • Simple, object oriented, and familiar
  • Robust and secure
  • Architecture neutral and portable
  • High performance
  • Interpreted, threaded, and dynamic

12)Why java is not a 100% oops?

Many people say this because Java uses primitive types such as int, char, double. But then all the rest are objects. Confusing question..

13)What is a resource bundle?
In its simplest form, a resource bundle is represented by a text file containing keys and a text value for each key.

14) What is transient variable?

Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the value of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null .

15)What is Collection API?

The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces.
Example of classes : HashSet , HashMap , ArrayList , LinkedList , TreeSet and TreeMap .
Example of interfaces : Collection , Set , List and Map.

16)What is singleton class?where is it used?
Singleton is a design pattern meant to provide one and only one instance of an object. Other objects can get a reference to this instance through a static method (class constructor is kept private). Why do we need one? Sometimes it is necessary, and often sufficient, to create a single instance of a given class. This has advantages in memory management, and for Java, in garbage collection. Moreover, restricting the number of instances may be necessary or desirable for technological or business reasons--for example, we may only want a single instance of a pool of database connections.

Page 1


Download
Netbeans IDE 5.5.1. Download
J2SE SDK Download J2RE Download Application Server Download Latest JDK Download JCreator Download JDevloper Download