Annamalai University M.Sc I.T 2k4-2k9
Welcome To AUMSCIT ForuM.
Our Farewell Day Photos are present @ Announcement Section.
Annamalai University M.Sc I.T 2k4-2k9
Welcome To AUMSCIT ForuM.
Our Farewell Day Photos are present @ Announcement Section.
Annamalai University M.Sc I.T 2k4-2k9
Would you like to react to this message? Create an account in a few clicks or log in to continue.


This Forum will act as a bridge to connect students of M.Sc I.T 2004-2009 batch belongs to Annamalai University, TN, India
 
HomeGalleryLatest imagesSearchRegisterLog in
Hi, our Farewell Day Celebration Photos are available @ Announcement Section

 

 Complete Java Interview Question

Go down 
AuthorMessage
arunkumar

arunkumar


Male
Number of posts : 209
Age : 38
Location : CDM,IndiA
Job/hobbies : Till now Student
Registration date : 2008-10-21

Complete Java Interview Question Empty
PostSubject: Complete Java Interview Question   Complete Java Interview Question I_icon_minitimeSun May 03, 2009 9:51 pm

Complete Java Interview Question

Question: 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 instantiate 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.


Question: Can you make an instance of an abstract class? For example - java.util.Calender is an abstract class with a method getInstance() which returns an instance of the Calender class.
Answer: No! You cannot make an instance of an abstract class. An abstract class has to be sub-classed. If you have an abstract class and you want to use a method which has been implemented, you may need to subclass that abstract class, instantiate your subclass and then call that method.


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

Question: What is the main difference between Java platform and other platforms?
Answer: The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms. The Java platform has two components:

1. The Java Virtual Machine (Java VM)

2. The Java Application Programming Interface (Java API)

Question: What is the Java Virtual Machine?
Answer: The Java Virtual Machine is a software that can be ported onto various hardware-based platforms.

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

Question: Is Java code slower than native code?
Answer: Not really. As a platform-independent environment, the Java platform can be a bit slower than native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode compilers can bring performance close to that of native code without threatening portability.

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

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.

Question: . How are Observer and Observable used?
Answer: Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

Question: What is synchronization and why is it important?
Answer: With respect to multi threading, 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.

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

Question: How are Observer and Observable used?
Answer: Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

Question: 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.
__________________
Question: 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.


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

Question: Can a lock be acquired on a class?
Answer: Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.

Question: What's new with the stop(), suspend() and resume() methods in JDK 1.2?
Answer: The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.

Question: What is the preferred size of a component?
Answer: The preferred size of a component is the minimum component size that will allow the component to display normally.

Question: 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.
Question: 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" Run able 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.
Back to top Go down
http://cybersak.blogspot.com
 
Complete Java Interview Question
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Annamalai University M.Sc I.T 2k4-2k9 :: Noticeboard :: Career Tips & Suggestion-
Jump to: