Java Interview Questions
  • 1      Can there be an abstract class with no abstract methods in it? Yes, But abstract method must have with abstract class.

    2.     Can an interface be final? Can’t. Because abstract methods want to implement in the last concrete class

    3.     Can interface have an inner class? Can have an inner class

    4.     Can we define private and protected modifiers for variable in the interface? Can’t. can use only finale variable and public abstract methods

    5.     What is a local, member variable?
    ·         Local – variable declared within the method called local variable
    ·         Member – variable declared within the class but not any method is called member variable

    6.     Difference between interface and abstract class?
    ·         Abstract class defines with method
    ·         Interface declares only with method

    7.     What do you mean by RMI and how it will works?
    ·         RMI – Remote Method Invocation
    ·         Can work with remote objects
    ·         Protocol – RMI-IIOP

    8.     JDBC-ODBC bridge is not multithread

    9.     Class Loader – Class loader is the one which loads class to JVM

    10.   What are the statuses of the thread?
    ·         New
    ·          
    ·         Runnable
    ·         Not Runnable
    ·         Dead

    11.   What is the socket? Socket is an endpoint for communication between two machine

    12.   How to invoke any external process in java?
    ·         Runtime.getRunTime()

    13.   What is the base class for the error and exception?
    ·         Throwable

    14.   Package?
    ·         Group of class gather into single unit called package

    15.   What is JVM? Java Virtual Machine and it is an interpreter, Totally independent from the operating system.java compiler compile the source code into Byte code and JVM reads the Byte code and convert to the machine code.JVM is the part of the JRE (Java Run time Environment)

    16.   What is the final key word denotes?
    ·         It is denotes final implements for the class, method and variables
    ·         Class – Cannot extends
    ·         Method – Cannot override
    ·         Variable – Cannot change the initialized value 

    17.   Difference between ArrayList and LinkedList?
    ·         ArrayList – Can access  randomly
    ·         LinkedList – Can access sequentially

    18.   There can be abstract class with no abstract methods but there has abstract methods it should be an abstract class

    19.   Explain different way of using threads
    ·         Implementing using runnerble interface
    ·         Extends the thread class

    20.   What are passing by reference and pass by values?
    ·         pass by reference – copy of the reference will be parsed(object)
    ·         pass by value – copy of the bit pattern will be parsed(primitives)

    21.   What is HashMap and Map?
    ·         Map is an interface
    ·         HashMap is a class

    22.   Difference between vector and ArrayList?
    ·         Vector is synchronized
    ·         ArrayList is not synchronized

    23.   Difference between Swing and AWT?
    ·         Swing – Light Weight / fast / It doesn't invoke native methods.
    ·         AWT – Heavy Weight / slow / Every graphical units it will invoke native methods

    24.   Difference between constructor and methods?
    ·         Constructer – Member function of a class
                           Same name of the class
                           No return types
                           Invokes using new operator
    ·         Methods – Is an ordinary function of a class
                      It has its own name
                      Has return type
                      Invoke using Dot (.) Operator

    25.   Define the access modifiers?
    ·         Public – public class is visible in other package
    ·         Private – variable and methods can access within the class
    ·         Protected - Is available to all classes in the same package and also available to all subclasses          
                      Of the class that owns the protected feature.

    26.   What is a marker interface? An interface with no methods

    27.   Static method cannot override, but can redeclare

    28.   What is object Oriented Programmed? It is a problem solving techniques to develop software system. it’s a techniques to think  real world in term of objects

    29.   Need Object to deal with non static variables and methods

    30.   Abstract class  cannot instantiated (Cannot create class’s object )

    31.   Don’t have multiple class inheritances , But have multiple interface inheritance

    32.   Interface/abstract class cannot instantiated.

    33.   GRASP pattern (General Responsibility Assignment Software Patterns (or Principles),)

    ·         Who should be responsible for creating a new instance of some class?  -  Creational Design Pattern
    ·         Coupling is a measure of how strongly one element is connected to, has knowledge of, or relies on other elements.
    ·         How to keep complexity manageable? – Cohesion

    34.   Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine

    35.   A Web server exclusively handles HTTP requests

    36.   Application server serves business logic to application programs through any number of protocols.

    37.   Applet is a simple java programe embedded to the web application

    38.   Java Applets are usually used to add small, interactive components or enhancements to a Webpage

Reviewed by Pubudu Dewagama on 10:55:00 PM Rating: 5

No comments: