1. what is a transient variable?

  •  A transient variable is a variable that whose value is not going to be serialized

2. What is synchronization?

  • With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources.
  •  Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object’s value. This often leads to significant errors.

3. What’s new with the stop(), suspend() and resume() methods in JDK 1.2? 

  • The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.

4. Is null a keyword?

  •  "null"  is not a keyword. .null is a literal.

5. What state does a thread enter when it terminates its processing?

  • When a thread terminates its processing, it enters the dead state.

6. What is the Collections API?

  • The Collections API is a set of classes and interfaces that support operations on collections of objects.

7. What is the List interface?

  • The List interface provides support for ordered collections of objects which allows duplicate elements also.

8. What is the Vector class?

  • The Vector class provides the capability to implement a growable array of objects

9.Can we instantiate Abstract class?

  • We can not create object for abstract class directly. but indirectly through sub class object we can achieve it.

10.What is the first keyword used in a java program?

  • Its "package" keyword.

11.When a class should be defined as final?

  • If we do not want allow subclasses.
  • If we do not want to extend the functionality.

12.Can we declare abstract method as static?

  • No, we are not allowed to declare abstract method as static.
  • It leads to compilation error: illegal combination of modifiers abstract and static.

13.Can we apply abstract keyword to interface?

  • Yes, it is optional.
  • abstract interface A{}

14.Can we write empty interface?

  • Yes it is possible it is marker interface.
  • interface A{}

15.Can we declare interface as final?

  • No, it leads to compile time error. Because it should allow sub class.

16.How to solve ClassCastException?

  • To solve  ClassCastException we should use instanceof operator.
  • obj instanceof class_name

17. Is “xyz” a primitive value? 

  • No, it is not primitive it is string literal.

18.When is an object subject to garbage collection? 

  • An object is subject to garbage collection when it becomes unreachable to the program in which it is used.

19.What method must be implemented by all threads? 

  • The run() method, whether they are a subclass of Thread or implement the Runnable interface.


20.What happens if an exception is not caught?

  • An uncaught exception results in the uncaughtException() method of the thread’s ThreadGroup being invoked, which eventually results in the termination of the program in which it is thrown.

21.How are this() and super() used with constructors?

  • this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

22.Under what conditions is an object’s finalize() method invoked by the garbage collector?

  • The garbage collector invokes an object’s finalize() method when it detects that the object has become unreachable.

23.What restrictions are placed on method overloading? 

  • Methods should have same name  and defer in parameters.

24.When does the compiler supply a default constructor for a class? 

  • The compiler supplies a default constructor for a class if no other constructors are provided.

25.What modifiers can be used with a local inner class?

  • A local inner class may be final or abstract.

For More Questions Check below on your interest:

1. Concept and Interview Program

2. Concept and Interview Questions

3. 0-3 Years Core Java Interview Questions



1. Top 15 Garbage Collection Interview Questions

2. Top 10 Oops Concepts Interview Questions 

3. Top 15 Java Interview Questions on Constructors

4. Top 10 Inheritance Interview Questions

5. Interview Programs on Strings

6. 10 Interesting Core Java Interview Coding Questions and Answers

7. Top 20 Basic Java Interview Questions for Frehsers 

8. Top 10 interview Question on Static keyword. 

9.Top 20 Java interview Questions on Increment and Decrement operators

10.Top 10 Interview Questions on main() method

11. Top 12 Java Experienced interview Programming Questions on Strings

12.Pattern Programs in java Part-1

13.Pattern Programs in java Part-2

14.Pattern Programs in java Part-3 

15. Collection framework interview programming questions 

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

2 comments for Top 25 Core java interview questions for freshers

  1. 17. Is “xyz” a primitive value? No, It's literal ))))))

    ReplyDelete
  2. Nice keep on posting new Q's..))

    ReplyDelete

Select Menu