• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Important java interview Qs

 
Nag Rao
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
O. Subramaniam
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jatin Kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answering 7 can start a Holy war! Java is pass by value always! http://www.javaranch.com/campfire/StoryPassBy.jsp
 
Sanjay Saxena
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sanjay Saxena
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can apply static, private, protected only to an inner Class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic