Sample Questions Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions  

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

Java Sample Questions ›› Java questions

Technical General Java Sample Questions

  1. What are the states of a thread?

    Answer: There are four states of thread:

      New
    • Runnable
    • Not runnable
    • Dead

  2. What is a socket?

    Answer: A socket is an endpoint for communication between two machines.

  3. How will you establish the connection between the servlet and an applet?

    Answer: Using the URL, I will create the connection URL.Then by openConnection method of the URL, I will establish the connection, through which I can be able to exchange data.

  4. What are the threads will start, when you start the java program?

    Answer: Finalizer, Main, Reference Handler, Signal Dispatcher.

  5. Is it necessary that each try block must be followed by a catch block?

    Answer: It is not necessary that each try block must be followed by a catch block.It should be followed by either a catch block OR a finally block.And whatever exceptions are likely to be thrown should be declared in the throws clause of the method.

  6. If I write return at the end of the try block, will the finally block still execute?

    Answer: Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute.The finally block will execute and then the control return.

  7. If I write System.exit (0); at the end of the try block, will the finally block still execute?

    Answer: No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.

  8. 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.

  9. What is synchronization and why is it important?

    Answer: With respect to multithreading, synchronization is the capability to controlthe 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 leads tosignificant errors.

  10. Why do we need wrapper classes?

    Answer: It is sometimes easier to deal with primitives as objects.Moreover most of the collection classes store objects and not primitive data types.And also the wrapper classes provide many utility methods also.Because of these resons we need wrapper classes.And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection.Also we can pass them around as method parameters where a method expects an object.

« Previous || Next »

Java Sample Question Number: 1-10| 11-20| 21-30| 31-40| 41-50| 51-60| 61-70| 71-80| 81-90| 91-100| 101-110| 111-120| 121-130| 131-140| 141-150| 151-160| 161-170| 171-180| 181-190| 191-200| 201-210| 211-220| 221-230| 231-240| 241-250| 251-260| 261-270| 271-280| 281-290| 291-300| 301-310| 311-320| 321-330
Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions

Other Sample Questions
Sample Interview Questions
Sample Teacher Interview Questions
Sample Citizenship Questions
Accuplacer Sample Questions
Science Bowl sample Questions
Driving Test Sample Questions
Sample Survey Questions Sample Essay Questions
Sample Behavioral Interview Questions

Copyright © 2004-2013, Best BSQ. All Rights Reserved.