[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Technical Interview Questions and Answers :: Java

    21 / 66

    Why multiple inheritance is not supported in java?
    Answer:

    Multiple inheritence is not supported in Java because of ambuiguity that it causes.

    Please Login First :
    Answer:

    Object cloning, clone() is the method available in Java for object duplication. In java, assignment operator only copies the reference and not the object. clone() is used for this.

    Please Login First :

    23 / 66

    What is Exception Handling? What is difference between Checked Exception and Unchecked Exception?
    Answer:

    An exception is a problem that arisesduring excecution. Checked exceptions are the exceptions that gets checked at the compile time. Unchecked exceptions are not checked at compile time, in Java all exceptions are unchecked exceptions.

    Please Login First :
    Answer:

    For numbers primitive data types are used normally, such as byte, int, long, double etc. But in programming, objects are sometimes required rather than primitive data types. For this, wrapper classes are available in Java.

    Please Login First :

    25 / 66

    What is Static and Dynamic binding in Java ?
    Answer:

    Static Binding: The binding which can be resolved at compile time by the compiler is known as static or early binding. All the static, private and final methods have always been bonded at compile-time.



    Dynamic Binding: When the compiler is not able to resolve the call/binding at compile time, such binding is known as Dynamic or late Binding. Overriding is a perfect example of dynamic binding as in overriding both parent and child classes have the same method. Thus while calling the overridden method, the compiler gets confused between parent and child class method(since both the methods have same name).

    Please Login First :

    26 / 66

    What are the differences between Static Binding and Dynamic Binding?
    Answer:

    The difference between static and dynamic binding in Java.




    1. Static binding happens at compile-time while dynamic binding happens at runtime.

    2. Binding of private, static and final methods always happen at compile time since these methods cannot be overridden. Binding of overridden methods happens at runtime.

    3. Java uses static binding for overloaded methods and dynamic binding for overridden methods.



     

    Please Login First :

    27 / 66

    can Java run in 1 MB RAM machine?
    Answer:

    No, java vannot run on 1MB RAM machine. The harware requirement is 128MB RAM.

    Please Login First :

    28 / 66

    How is JAVA platform independent?
    Answer:

    Java Virtual Machine(JVM) is what makes Java platform independent. A compiled java code creates a .class file which can then be run on any platform which has JVM installed on it.

    Please Login First :

    29 / 66

    What is JSP and Servelet?
    Answer:

    JSP(JavaServer Page) is used to create dynamically generated web pages. JSP is similar to ASP and PHP but it uses Java programming language. JavaServlet extends the capabilities of the server. Servlet can respond to any types of requests, they most commonly implement applications hosted on Web servers. Such Web servlets are the Java counterpart to other dynamic Web content technologies such as PHP and ASP.NET.

    Please Login First :

    30 / 66

    Difference between final, finally and finalize?
    Answer:

    Final:




    1. Final is a keyword.

    2. Final is used to apply restrictions on class, method, and variable. The final class can't be inherited, final method can't be overridden and final variable value can't be changed.



    Final Example:



    class FinalExample{



    public static void main(String[] args){



    final int x=100;



    x=200;//Compile Time Error



    }}



    Finally:




    1. Finally is a block.

    2. The finally block always executes when the try block exits. This ensures that the final block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling - it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a final block is always a good practice, even when no exceptions are anticipated.



    Finally Example:



    class FinallyExample{



    public static void main(String[] args){



    try{



    int x=300;



    }catch(Exception e){System.out.println(e);}



    finally{System.out.println("finally block is executed");}



    } } 



    Finalize:




    1. Finalize is a method.

    2. Finalize is used to perform cleanup processing just before an object is a garbage collected. The runtime system calls its finalize() method. You can write system resources release code in finalize() method before getting garbage collected.



    Finalize Example:



    class FinalizeExample{



    public void finalize(){System.out.println("finalize called");}



    public static void main(String[] args){



    FinalizeExample f1=new FinalizeExample();



    FinalizeExample f2=new FinalizeExample();



    f1=null;



    f2=null;



    System.gc();



    }}

    Please Login First :