This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi all, I came across the following interview questions in some other forum. Can somebody discuss the answers so that it will be useful for all?. 1.Can you apply static, private, protected to a Class and a Constructor?Reasons. 2.What is finalize() method? why is it protected? 3.what is singleton and use of it? 4.what are joins in db? differentiate inner and outer joins.//db question 5.Are there virtual functions in java like in C++? 6.What is java reflection API? 7.Is java pass by val or pass by ref.explain. 8.What is serialization in java. thanks, Nag.
Reflection: Querying a class about its methods and properties is called Reflection.Reflection API is use dot achieve this. Serialization: Is the method of converting complex objects into a stream of bytes.
I think finalize() method in an object is used to clean up the resources before the object gets garbage collected.It is called just before GC.I don't know why it is a Protected method? Singleton pattern is designed for creating only one instance of a class so that the remaining apps can share that single object.Connection pool is an example.ANy other examples???
Can you apply static, private, protected to a Class and a Constructor? Reasons
A static member is always associated to a class NOT to an instance(object) of the class as we know constructors are used to construct an instance. So we can not apply static to a constructor. They both are meant for different purposes.
If a constructor is private that means that constructor can only be used within the same class. This means other classes can not instantiate this class. Private constructors are usually used to create Singleton objects. I think protected constructor is a valid but then this class can only be instantiated by the subclasses.
Joined: Dec 12, 2001
We can apply static, private, protected only to an inner Class.