• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GArbage collection question

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class Archer {
public void finalize(){
System.out.println("finalizing");
}

}
public class Shula{
String[] sa= new String[10];
public static void main(String argv[]){
new Shula();
}
public Shula(){
String s = new String("Shula");
int i = 99;
i = null;
Archer a = new Archer();
a=null;
System.gc();
}
}


1. Compile time error
2 Compilation and output of "finalizing" at runtime
3 Compilation but no output at runtime
4 Compilation but runtime exception

The Correct Answer is
1) Compile time error.

Please explain this
saource :http://www.examulator.com
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, what happened when you compiled it? What error did the compiler report?

Hint: The error is somewhere near these lines...



Henry
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic