REGISTER FREE to Receive Instant Job

Saturday, 6 December 2014

Core Java Interview Questions

1-Can we override static method?
 No, you can't override the static method because they are the part of class not object.
2- Why we cannot override static method?
It is because the static method is the part of class and it is bound with class whereas instance method is bound with object and static gets memory in class area and instance gets memory in heap.
3-Can you have virtual functions in Java?
Yes, all functions in Java are virtual by default.
4-What is covariant return type?
Now, since java5, it is possible to override any method by changing the return type if the return type of the subclass overriding method is subclass type. It is known as covariant return type.
5-What is blank final variable?
A final variable, not initalized at the time of declaration, is known as blank final variable.
6-Can we intialize blank final variable?
Yes, only in constructor if it is non-static. If it is static blank final variable, it can be initialized only in the static block.
7-Can you declare the main method as final?
Yes, such as, public static final void main(String[] args){}.
8-What is Runtime Polymorphism?

In this process, an overridden method is called through the reference variable of a super class. The determination of the method to be called is based on the object being referred to by the reference variable.
9-What is the difference between static binding and dynamic binding?

In case of static binding type of object is determined at compile time whereas in dynamic binding type of object is determined at runtime.
10-What is the difference between abstraction and encapsulation?

Abstraction hides the implementation details whereas encapsulation wraps code and data into a single unit.
11-Can there be any abstract method without abstract class?

No, if there is any abstract method in a class, that class must be abstract.
12-Can you use abstract and final both with a method?

No, because abstract method needs to be overridden whereas you can't override final method.
13-Is it possible to instantiate the abstract class?

No, abstract class can never be instantiated.
14-What is interface?

Interface is a blueprint of a class that have static constants and abstract methods.It can be used to achieve fully abstraction and multiple inheritance.
15-Can you declare an interface method static?

No, because methods of an interface is abstract by default, and static and abstract keywords can't be used together.
16-Can an Interface be final?

No, because its implementation is provided by another class.
17-What is marker interface?

An interface that have no data member and method is known as a marker interface.For example Serializable, Cloneable etc.
18-Can we define private and protected modifiers for variables in interfaces?

No, they are implicitly public.

19-Can I import same package/class twice? Will the JVM load the package twice at runtime?

One can import the same package or same class multiple times. Neither compiler nor JVM complains about it.But the JVM will internally load the class only once no matter how many times you import the same class.

20-What is static import ?

By static import, we can access the static members of a class directly, there is no to qualify it with the class name.
21-Is it necessary that each try block must be followed by a catch block?

22-Is there any case when finally will not be executed?

23-Can subclass overriding method declare an exception if parent class method doesn't throw an exception ?

Yes but only unchecked exception not checked.
24-What is exception propagation ?

25-What is the meaning of immutable in terms of String?

The simple meaning of immutable is unmodifiable or unchangeable. Once string object has been created, its value can't be changed.
26-Why string objects are immutable in java?

Because java uses the concept of string literal. Suppose there are 5 reference variables,all referes to one object "sachin".If one reference variable changes the value of the object, it will be affected to all the reference variables. That is why string objects are immutable in java.
27- Why java uses the concept of string literal?

To make Java more memory efficient (because no new objects are created if it exists already in string constant pool).
28-How can we create immutable class in java ?

We can create immutable class as the String class by defining final class.
29- Is there any difference between nested classes and inner classes?

Yes, inner classes are non-static nested classes i.e. inner classes are the part of nested classes.
30-Can we access the non-final local variable, inside the local inner class?

No, local variable must be constant if you want to access it in local inner class.


    hotmail login | red ball

    animal jam | five nights at freddy's | hotmail login

  3. Thanks for sharing this marvelous post. I m very pleased to read this article.Sign in pogo


    norton activation
    or directly visit .
    you can find more topics there.We love to help you.

  5. Thank you so much for giving pieces of information. Playing games is the best way of entertainment from the very beginning of human is one of the biggest and oldest online gaming websites present on the internet. It provides more than 100 casual games from big computer gaming brands like PopCap Games, Hasbro, etc. visit here: Pogo Game Is Not Loading

  6. Follow to set if you our
    router is not working after reset
    . Click on link to know more.

    Happy New Year 2019 Wishes Messages Sms in Bengali
    Merry Christmas 2018 SMS, Wishes, Messages, Greetings in Bengali
    Merry Christmas 2018 Wishes Messages in Marathi,funny christmas text sms


Popular Posts

Powered by Blogger.

About Me

My photo
