Java Interview Questions

Java Technical Questions with Answers

What modifiers may be used with top-level class?
public, abstract and final can be used for top-level class.

What are inner class and anonymous class?
Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors.

What is a package?
A package is a collection of classes and interfaces that provides a high-level layer of access protection and name space management.

Java Job Interview Questions

What is Garbage Collection and how to call it explicitly?
When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as garbage collection. System. gc() method may be used to call it explicitly.

What is finalize() method?
finalize () method is used just before an object is destroyed and can be called just prior to garbage collection.

What are Transient and Volatile Modifiers?
Transient: The transient modifier applies to variables only and it is not stored as part of its object’s Persistent state. Transient variables are not serialized. Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program.

Basic Java Interview Questions

1. Why do you prefer Java?

Answer: write once ,run anywhere.

2. Name some of the classes which provide the functionality of collation?

Answer: collator, rulebased collator, collationkey, collationelement iterator.

3. Awt stands for? and what is it?

Answer: AWT stands for Abstract window tool kit. It is a is a package that provides an integrated set of classes to manage user interface components.

4. why a java program can not directly communicate with an ODBC driver?

Answer: Since ODBC API is written in C language and makes use of pointers which Java can not support.

Java Web Programming Interview Questions

Question1:

What is a Servlet?

Answer: Servlets are modules of Java code that run in a server application (hence the name “Servlets”, similar to “Applets” on the client side) to answer client requests.

Question2:

What advantages does CMOS have over TTL(transitor transitor logic)? (ALCATEL)

Answer:

  • low power dissipation
  • pulls up to rail
  • easy to interface

How is Java unlike C++? (Asked by Sun)

Answer:

Advanced Java Interview Questions

Q:In Java, what is the difference between an Interface and an Abstract class?

A: An Abstract class declares have at least one instance method that is declared abstract which will be implemented by the subclasses. An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior.

Q: Can you have virtual functions in Java? Yes or No. If yes, then what are virtual functions?

Pages (21): [1] 2 3 4 » ... Last »