This document contains 25 questions about Java concepts related to packages, variables, object references, serialization, exceptions, and custom exceptions. Some of the questions ask about importing packages, declaring vs defining variables, default object reference values, serialization methods and customization, checked vs runtime exceptions, and creating custom exception classes and objects.
This document contains 25 questions about Java concepts related to packages, variables, object references, serialization, exceptions, and custom exceptions. Some of the questions ask about importing packages, declaring vs defining variables, default object reference values, serialization methods and customization, checked vs runtime exceptions, and creating custom exception classes and objects.
This document contains 25 questions about Java concepts related to packages, variables, object references, serialization, exceptions, and custom exceptions. Some of the questions ask about importing packages, declaring vs defining variables, default object reference values, serialization methods and customization, checked vs runtime exceptions, and creating custom exception classes and objects.
This document contains 25 questions about Java concepts related to packages, variables, object references, serialization, exceptions, and custom exceptions. Some of the questions ask about importing packages, declaring vs defining variables, default object reference values, serialization methods and customization, checked vs runtime exceptions, and creating custom exception classes and objects.
1. Does importing a package imports the subpackages as well? Example: Does
importing com.MyTest.* also import com.MyTest.UnitTests.*? 2. What is the difference between declaring a variable and defining a variable? 3. What is the default value of an object reference declared as an instance variable? 4. Can a top level class be private or protected? 5. What type of parameter passing does Java support? 6. Primitive data types are passed by reference or pass by value? 7. Objects are passed by value or by reference? 8. What is serialization? 9. How do I serialize an object to a file? 10. Which methods of Serializable interface should I implement? 11. How can I customize the seralization process? i.e. how can one have a control over the serialization process? 12. What is the common usage of serialization? 13. What is Externalizable interface? 14. When you serialize an object, what happens to the object references included in the object? 15. What one should take care of while serializing the object? 16. What happens to the static fields of a class during serialization? 17. Does Java provide any construct to find out the size of an object? 18. What are wrapper classes? 19. Why do we need wrapper classes? 20. What are checked exceptions? 21. What are runtime exceptions? 22. What is the difference between error and an exception? 23. How to create custom exceptions? 24. If I want an object of my class to be thrown as an exception object, what should I do? 25. If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object?