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. Which methods of Serializable interface should I implement?

    Answer: The serializable interface is an empty interface, it does not contain any methods.So we do not implement any methods.

  2. How can I customize the seralization process? i.e.how can one have a control over the serialization process?

    Answer: Yes it is possible to have control over serialization process.The class should implement Externalizable interface.This interface contains two methods namely readExternal and writeExternal.You should implement these methods and write the logic for customizing the serialization process.

  3. What is the common usage of serialization?

    Answer: Whenever an object is to be sent over the network, objects need to be serialized.Moreover if the state of an object is to be saved, objects need to be serilazed.

  4. What is Externalizable interface?

    Answer: Externalizable is an interface which contains two methods readExternal and writeExternal.These methods give you a control over the serialization mechanism.Thus if your class implements this interface, you can customize the serialization process by implementing these methods.

  5. What happens to the object references included in the object?

    Answer: The serialization mechanism generates an object graph for serialization.Thus it determines whether the included object references are serializable or not.This is a recursive process.Thus when an object is serialized, all the included objects are also serialized alongwith the original obect.

  6. What one should take care of while serializing the object?

    Answer: One should make sure that all the included objects are also serializable.If any of the objects is not serializable then it throws a NotSerializableException.

  7. What happens to the static fields of a class during serialization? Are these fields serialized as a part of each serialized object?

    Answer: Yes the static fields do get serialized.If the static field is an object then it must have implemented Serializable interface.The static fields are serialized as a part of every object.But the commonness of the static fields across all the instances is maintained even after serialization.

  8. Does Java provide any construct to find out the size of an object?

    Answer: No there is not sizeof operator in Java.So there is not direct way to determine the size of an object directly in Java.

  9. Does importing a package imports the subpackages as well? e.g.Does importing com.MyTest.* also import com.MyTest.UnitTests.*?

    Answer: Read the system time just before the method is invoked and immediately after method returns.Take the time difference, which will give you the time taken by a method for execution.To put it in code...long start = System.currentTimeMillis ();method ();long end = System.currentTimeMillis ();System.out.println ("Time taken for execution is " + (end - start));Remember that if the time taken for execution is too small, it might show that it is taking zero milliseconds for execution.Try it on a method which is big enough, in the sense the one which is doing considerable amout of processing.

  10. What are wrapper classes?

    Answer: Java provides specialized classes corresponding to each of the primitive data types.These are called wrapper classes.They are e.g.Integer, Character, Double etc

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