Set1 - Java

 Error: 

1. 

package utils;


public class test {


public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println(10/00); //error

System.out.println(10/0.0f); //infinity

}


}



2. 


package utils;


public class duper {


public duper (int a)

{}

}


package utils;


public class sub1 extends duper {

public static void main(String[] args) {

new Super();

}

}


o/p:

//Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

//Super cannot be resolved to a type

//

//at utils.sub1.main(duper.java:13)


3. 

public static void main(String[] args) {

int a; 

a=a+1;

System.out.println("value of a is: "+a);

}


o/p:  //Exception in thread "main" java.lang.Error: Unresolved compilation problem: . 



Garbage Collector:


1. difference between system.gc and runtime.gc 

Both are garbage collector but system.gc is generally used as this is a class method

runtime.gc is an instance variable i.e. declared with the instance of the class like when we create object of class

finalize is called after finding the object is unreachable. 

        

        2. finalize() is defined in object class and called just before it is garbage collected. 

3. Garbale collector is not applied on reachable objects

4. Exception by finalize() will halt it to be garbage collected. rest/jvm will continue


Comments

Popular posts from this blog

Test Batch Runner - Run QTP Scripts from xls file

Selenium: db and excel data into maps

Python: get entire workbook data cell by cell