Only Institute
to provide recording daily after class to students. you can practice whole day under faculty guidance. where test and mockup tests are taken regularly. provides all mobile nos of old students on website.

Core Java Interview Questions - Part 1

Resurrection can happen in 'finalize' method which will prevent GC to reclaim the object memory. However this could be done only once. Next time GC will not invoke 'finalize' method before garbage collection.
Overriding methods cannot throw more generic exception than base method.
An 'inner class' is part of the implementation of its enclosing class (or classes). As such, it has access to the private members of any enclosing class. Top-level nested classes are declared with 'static' keyword. Top level inner classes can be accessed / instantiated without an instance of the outer class. Can access only static members of outer class. Cannot access instance variables or methods of the enclosing class. Non-static inner classes which are declared without 'static' keyword cannot exist without enclosing class. Can access all the features (even private) of the enclosing outer class. Local classes are defined inside a block (could be a method, a constructor, a local block, a static initializer or an instance initializer). Cannot be specified with 'static' modifier. A class cannot have non-static inner interface. All inner classes except anonymous can be 'abstract' or 'final'.
If both the interface have same variable and the variable is not declared in implementing class, the compiler will throw an ambiguous error.
Dictionary is a class and not an interface.
Member variables are resolved at compile time.
Static Runtime runtime=Runtime.getRuntime();
long start,end;
Object obj;
runtime.gc();
start=runtime.freememory();
obj=new object();
end= Runtime.freememory();
System.out.println('size of obj'�+ (start-end)+ 'bytes'�);
[Note: Since GC can't be enforced in java the result is not always predictable.]
							

	class S1{
    public string S= “ S1”;
    public string gets() {
    returns S;
    }
    }
    class S2 extend S1 {
    public string S = “ S2”;
    public string gets() {
    return S;
    }
    }
    public class shadow{
    public static void main(String S[]) {
    S1 s1 = new S1();
    S2 s2= new S2();
    System.out.println("Print S1 " + s1.s);
    System.out.println("Print S1 " + s2.s);
    s1=s2;
    System.out.println("Print S1 now " + s1.S) ;
    System.out.println( "Print s1.gets() now " + s1.gets());
    }
    }
Yes, we can override variables but variables when overridden shadows the super class variable. Print S1 S1 Print S1 S2 Print S1 now S1 Print S1.gets() now S2
						  
b. [float f = 100.00/0.0. Float division by zero returns NAN (not a number) instead of exception.]

	class S1 {
    string S= “ S1”;
    public string gets (){
     return S;
    }
    void display () {
     System.out.println("Display in S1 " + S);
    }
    }
    class S2 extends S1{
    string S= “ S2”;
    void display(){
    super.display();
    System.out.println("Display in S2 " +S);
    }
    }
    public class shadow 2 {
    string s =” base”;
    public static void main(String s[]) {
    S2 s2=new S2();
    S2.display ();
    S1 s1=new S1();
    System.out.println("Print S1 " + s1.gets());
    System.out.println("Print S2 " + s2.gets());
    }
}
Methods access variables only in the context of the class they belong to will be used for base class or super class. If subclass calls super class method, it will access super class variable. Display in S1 S1 Display in S2 S2 Print S1 S1 Print S2 S1
False, as map does not implement collection.
Yes, a class can implement two interfaces which has got methods with same name and signatures.
Interface cannot be declared 'final' as they are implicitly 'abstract'.
'Finalize' is not implicitly chained. A 'finalize' method in sub-class should call 'finalize' in super class explicitly as its last action for proper functioning. Compilers does not enforce this check.
All methods in an interface are implicitly 'public', 'abstract' but never 'static'.
Volatile can be applied only to variables, not for 'static' or 'final'. Declaring a variable volatile indicates that it might be modified asynchronously, so that thread will get correct value and used in multi processor environment.
All variables in an interface are implicitly static , public and final. They cannot be transient or volatile. A class can shadow the interface variable with its variable while implementing.
Transient variables are not stored as object's persistence state and is not serialized for security. Transient variables may not be final or static. Compilers do not give any errors as static variables and anyways they are not serialized.