Java Interview Questions

Showing Questions 1641 - 1646 of 1646 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page:
  •  

    What is the difference between Abstract class and Interface

    Answered by Scott on 2005-05-12 10:03:06: An abstract class can contain non-abstract methods which do not have to be overridden in the subclass.  There is no difference between a fully abstract class (all methods declared as abstract and all fields are public static final) and an interface.

    harihb

    • Jun 2nd, 2011

    Versioning and default functionality.Let's say that you have an abstract class called Human with a functionality walk(). Person A, B that extends abstract class gets the default functionality '...

  •  

    Predict the output of the given code:

    javapublic class Test {
    private static String msg = "HCL ";
    static{
    Thread t = new Thread(new Runnable(){
    public void run(){
    msg = "Technologies ";
    }
    });
    t.start();
    }
    public static void main(String[] args){
    System.out.print(msg);
    }}
    a) Compiles and prints HCL
    b) Compiles and prints Technologies
    c) Compiles and...

    srk

    • Jan 29th, 2015

    A

    ankit

    • Dec 19th, 2014

    Answer is coming as HCL because there are two threads main and t and both are sharing the common resource ( static variable msg ) . Thread t is getting created and brought into runnable state ( by ca...

  •  

    What is a transient variable

    A transient variable is a variable that may not be serialized.

    Star Read Best Answer

    Editorial / Best Answer

    sivagopal  

    • Member Since Jun-2009 | Jun 8th, 2009


    A variable that won't be allowed for object serialisation. so that the state of the value will always be defaulted after the deserialisation.
    For example a variable x's value is set to 9, it's default value is '0' say, when the object has been serialized having x's value 9, after deserialisation will be defaulted to '0'

    Use: In Java, serialization of an object allowed only when all the underlying objects of the object that is currently under serialization contains has a relationship, will not be allowed, some times the developer has no choice of implementing serializable marker interface on some classes as the classes might have been arrived from a third party and the developer has no control over them, but the developer needs to serialize the object's state, then the developer has the choice of marking the objects that not serializable as transient.

    Yogesh Bombe

    • Aug 11th, 2015

    A transient variable is a variable that cannot be serialized. The transient keyword can be used to indicate the Java Virtual Machine that the variable is not part of the persistent state of the object.

    raisha

    • May 6th, 2013

    transient is a keyword....If a variable is declared as a Transient ,we cant serialize that variable.. The important points about Transient are: 1) Transient keyword can only be applied to fields or ...

Showing Questions 1641 - 1646 of 1646 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page: