Sunday, April 21, 2013

Java Interview Questions and Answers Part 6

Q41.  What are wrapped classes?

Wrapped classes are classes that allow primitive types to be accessed as objects.


Q42. Does garbage collection guarantee that a program will not run out of memory?

No, it doesn't. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Q43. What is the difference between preemptive scheduling and time slicing?

Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.

Q44. Name Component subclasses that support painting ?

The Canvas, Frame, Panel, and Applet classes support painting.

Q45.What is a native method?

A native method is a method that is implemented in a language other than Java.

Q46. How can you write a loop indefinitely?

for(;;)--for loop; while(true)--always true, etc.

Q47. Can an anonymous class be declared as implementing an interface and extending a class?

An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

Q48. What is the purpose of finalization?

The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

Q49. When should the method invokeLater()be used?

This method is used to ensure that Swing components are updated through the eventdispatching thread.

Q50. How many methods in Object class?

This question is not asked to test your memory. It tests you how well you know Java. Ten in total.

clone()
equals() & hashcode()
getClass()
finalize()
wait() & notify()
toString()

No comments:

Post a Comment

Automatic Traffic Exchange

YallaTech Facebook page