Monday, 13 January 2014

Java Language Interview Question and Answers : 5

Posted by Pritam  |  at  04:56 No comments

21.What are wrapper classes?
primitive data types may be converted into object types by using the wrapper classes contained in the java.lang package.
Exampes : int, float, long, char, double
22.What is the difference between an instance variable and a static variable?
Class variables are called static variables. There is only one occurrence of a class variable per JVM per class loader.When a class is loaded the class variables are initialized.
Instance variables are non-static and there is one occurrence of an instance variable in each class instance.Also known as a member variable or a field.
23Where and how can you use a private constructor?
Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing.The instantiation is done by a public static method (i.e. a static factory method) within the same class.
24.What is type casting?
Type casting means treating a variable of one type as though it is another type.
Examples :
int m = 5;
byte n =i;
25.What is a user defined exception?
User defined exceptions may be implemented by defining a new exception class by extending the Exception class.

<<<PREV                                                                                              NEXT>>>

About the Author

Write admin description here..

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

Related posts

0 comments:

We Will Appreciate Your Comment As Complement

© 2013 Knowledge To Grab. WP Theme-junkie converted by K-Grab
Blogger templates. Proudly Powered by Blogger.
back to top