UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

class HappyGarbage01 { public static void main(String args[]) { HappyGarbage01 h = new HappyGarbage01(); h.methodA(); /* Line 6 */ } Object methodA() { Object obj1 = new Object(); Object [] obj2 = new Object[1]; obj2[0] = obj1; obj1 = null; return obj2[0]; } } Where will be the most chance of the garbage collector being invoked? A. After line 9 B. After line 10 C. After line 11 D. Garbage collector never invoked in methodA()

Asked by Last Modified  

14 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Trainer

Hello Shrikant who told you that you can explicity call garbage collector. You cann't call gc explicity even when you use System.gc() it is not guranteed that gc will be invoked it is all up to JVM when an object is eligible for garbage collection.even when you use finalise method that is a protected...
read more
Hello Shrikant who told you that you can explicity call garbage collector. You cann't call gc explicity even when you use System.gc() it is not guranteed that gc will be invoked it is all up to JVM when an object is eligible for garbage collection.even when you use finalise method that is a protected method of java.lang.Object class read less
Comments

D
Comments

Master

D. Garbage collector never invoked in methodA()
Comments

Core Java, Angular 2/4/6, J2EE, Spring Boot

Answer is C ... because object 1 is referred to null. So it will be eleigible for GC.
Comments

Experience in Java and Android Trainer.

Garbage collector never invoked in methodA()
Comments

JAVA,JDBC,SERVLETS,JSP,STRUTS,SPRNG,HIBERNATE

After line 11
Comments

After line 11 (because memory location allocated to obj1 will be freed as part of line 12 . so obj1 is eligible for garbage collection)
Comments

Java/J2EE, B.E./B.Tech/MCA SubjectsTraining

D
Comments

Java Techonologies

It takes place after line 6, but there is no possibility to check when garbage collector is called/invoked since it JVM dependent.
Comments

IT Professional Trainer with 15 years of experience in IT Industry

D
Comments

View 12 more Answers

Related Questions

Is it possible to learn java at home without coaching in one month?
It all depends on you. If you are already aware of programming then it is definetly possible to learn java at home. But if learn through a tutor then you can learn easily.
Pritom
0 0
5
Presently is swings and applets are important in java ?
Yes for standalone application development
Mahender
Hi , this is Mithun Ghosh from Kolkata. I want a suggestion about the course content of teaching Java starting from core to Advanced level. Please anyone do help with a legible course content. Thanks in advance -- Thanks & Regards, Mithun Ghosh
Hi Mithun, This is AkiraITSolutions, We do provide real time training with real time employees, who ever having more than 10 years of IT Experience. For further details please feel free to reach us.
Mithun Ghosh

I am a fresher and I want to become a Java developer, so what is necessary to crack the Java interview ? 

For an interview, you should prepare all the basic questions of Java , class, function and OOP concepts.
Dipesh

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

How to create Rest web services in Java
Web services are web application components that lets two different applications to communicate over the network.Let if an application which in written java provides web services can be communicated through...

What is a Programming Language
What is a Language? Language is a communication system of human. What is a programming Language? A programming Language is a formal constructed language design to communicate...

COMPILATION AND INTERPRETATION
Compilation and Interpertation Process javac (compiler) java(interpreter)high level code - > compile - > bytecode - > interperted - > machine code Bytecode...

Definition of Class and Object in Java
Object - Objects have states and behaviors. Example: A dog has states - colour, name, breed as well as behaviors - barking, eating, sleeping. An object is an instance of a class. Class - A class can be...

Differences Between HashMap vs HashSet In Java.
HashSet HashMap HashSet implements Set interface. HashMap implements Map interface. HashSet stores the data as objects. HashMap stores the data as key-value pairs. HashSet...

Recommended Articles

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more