| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|
#1 (permalink) | ||||||||||||||||||||
|
Member
Join Date: Jun 2008
Age: 24
Posts: 72
Thanks: 2 Thanked 27 Times in 20 Posts Thanks: 2
Thanked 27 Times in 20 Posts
Blog Entries: 2
Rep Power: 3
|
Core Java Questions Interview Ques n Answers-IV
Question: Explain garbage collection ?
Answer: Garbage collection is an important part of Java's security strategy. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects from the memory. The name "garbage collection" implies that objects that are no longer needed by the program are "garbage" and can be thrown away. A more accurate and up-to-date metaphor might be "memory recycling." When an object is no longer referenced by the program, the heap space it occupies must be recycled so that the space is available for subsequent new objects. The garbage collector must somehow determine which objects are no longer referenced by the program and make available the heap space occupied by such unreferenced objects. In the process of freeing unreferenced objects, the garbage collector must run any finalizers of objects being freed. Question: How you can force the garbage collection ? Answer: Garbage collection automatic process and can't be forced. We can call garbage collector in Java by calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected. Question: What are the field/method access levels (specifiers) and class access levels ? Answer: Each field and method has an access level:
Answer: If a field or method defined as a static, there is only one copy for entire class, rather than one copy for each instance of class. static method cannot accecss non-static field or call non-static method Example Java Code static int counter = 0; A public static field or method can be accessed from outside the class using either the usual notation: Java-class-object.field-or-method-name or using the class name instead of the name of the class object: Java- class-name.field-or-method-name Question: What are the Final fields & Final Methods ? Answer: Fields and methods can also be declared final. A final method cannot be overridden in a subclass. A final field is like a constant: once it has been given a value, it cannot be assigned to again. Java Code private static final int MAXATTEMPTS = 10; Question: Describe the wrapper classes in Java ? Answer: Wrapper class is wrapper around a primitive data type. An instance of a wrapper class contains, or wraps, a primitive value of the corresponding type. Following table lists the primitive types and the corresponding wrapper classes:
__________________
The early years were more about learning than about acting. I had to carry on my father’s work, which was a big challenge. Azim Premji |
||||||||||||||||||||
|
|
|
| The Following User Says Thank You to vijayrmca For This Useful Post: |
narayanarao1983 (01-07-08)
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| JAVA WEB SITES | yathish | JAVA Technologies | 2 | 20-11-08 12:11 AM |
| tips for interview | ozobalu | HR Questions | 9 | 23-09-08 12:32 AM |
| Dug it | yathish | Companies Info & Recruitment Process | 4 | 10-09-08 06:25 PM |
| Interview Questions | Pink | Other Queries | 15 | 20-08-08 03:37 AM |