0% found this document useful (0 votes)
52 views

Java

This document contains a list of 153 core Java interview questions and their brief explanations. Some of the topics covered include static blocks, method overloading vs overriding, abstract classes vs interfaces, exceptions, threads, nested classes, serialization, and type conversions. The questions range from basic concepts like classes and objects to more advanced topics like multithreading and exceptions handling.

Uploaded by

Veeresh Dodamani
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Java

This document contains a list of 153 core Java interview questions and their brief explanations. Some of the topics covered include static blocks, method overloading vs overriding, abstract classes vs interfaces, exceptions, threads, nested classes, serialization, and type conversions. The questions range from basic concepts like classes and objects to more advanced topics like multithreading and exceptions handling.

Uploaded by

Veeresh Dodamani
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

----::Core Java Interview QuesƟons::----

===================================================================================
=================

1. what are staƟc blocks and staƟc iniƟalizers in Java?


==>When a block is decorated or associated with the word static, it is called a
static block.

2.How to call one constructor from the other constructor?


==>using this().

3.What is method overriding in java?


==>If subclass (child class) has the same method as declared in the parent class,
it is known as method overriding in Java.

4.What is super keyword in java?


==>The super keyword in Java is a reference variable which is used to refer
immediate parent class object.

5.How to call immediate parent class constructor from the sub class
constructor?
==>Use of super() to access superclass constructor

6.Difference between method overloading and method overriding in java?


==> Overriding Overloading
1)Implements “runtime polymorphism” Implements “compile time polymorphism”
2)The method call is determined at runtime The method call is determined at
compile time
based on the object type
3)Occurs between superclass and subclass Occurs between the methods in the
same class
4)Have the same signature Have the same name, but the parameters
are different
(name and method arguments)
5)On error, the effect will be visible On error, it can be caught at
compile time
at runtime

7.Difference between abstract class and interface?


==> Abstract class
Interface
1) Abstract class can have abstract and non-abstract methods. |
Interface can have only abstract methods. Since Java 8, it can have default and
static methods also.
2) Abstract class doesn't support multiple inheritance. |
Interface supports multiple inheritance.
3) Abstract class can have final, non-final, static and non-static variables. |
Interface has only static and final variables.
4) Abstract class can provide the implementation of interface. |
Interface can't provide the implementation of abstract class.
5) The abstract keyword is used to declare abstract class. |
The interface keyword is used to declare interface.
6) An abstract class can extend another Java class and implement multiple Java
interfaces. | An interface can extend another Java interface only.
7) An abstract class can be extended using keyword "extends". | An
interface can be implemented using keyword "implements".
8) A Java abstract class can have class members like private, protected, etc. |
Members of a Java interface are public by default.

8.Why java is plaƞorm independent?


9.What is method overloading in java?
10.What is JIT compiler?
11.What is bytecode in java?
12.Difference between this() call statement and super() call statement in java?
13.Difference between this keyword and super keyword?
14.What is a class?
15.What is an object?
16.What is method in java?
17.What is encapsulaƟon?
18.Why main() method is public, staƟc and void in java?
19.Explain about main() method in java?
20.What is constructor in java?
21.What is difference between length keyword and length() method in java?
22.What is ASCII Code?
23.What is Unicode?
24.Difference between Character Constant and String Constant in java?
25.What are constants and how to create constants in java?
26.What are constants and how to create constants in java?
27.Explain Java Coding Standards for classes or Java coding convenƟons for
classes?
28.Explain Java Coding standards for interfaces?
29.Explain Java Coding standards for Methods?
30.Explain Java Coding Standards for variables?
31.What is ‘IS-A’ relaƟonship in java?
32.What is ‘HAS A’ relaƟonship in java?
33.Difference between ‘IS-A’ and ‘HAS-A’ relaƟonship in java?
34.Explain about instanceOf operator in java?
35.What does null mean in java?
36.Can we have mulƟple classes in single file?
37.What all access modifiers are allowed for top class?
38.What are packages in java?
39.Can we have more than one package statement in source file?
40.Can we define package statement aŌer import statement in java?
41.What are idenƟfiers in java?
42.What are access modifiers in java?
43.What are non-access modifiers in java?
44.What access modifiers can be used for class?
45.Explain what access modifiers can be used for methods?
46.Explain what access modifiers can be used for variables?
47.What is final access modifier in java?
48.Explain about abstract classes in java?
49.Can we create constructor in abstract class?
50.What are abstract methods in java?
51.What is an excepƟon in java?
52.State some situaƟons where excepƟons may arise in java?
53.What is ExcepƟon handling in java?
54.What is an error in Java?
55.What are advantages of ExcepƟon handling in java?
56.In how many ways we can do excepƟon handling in java?
57. List out five keywords related to ExcepƟon handling?
58.Explain try and catch keywords in java?
59.Can we have try block without catch block?
60.Can we have mulƟple catch block for a try block?
61.Explain importance of finally block in java?
62.Can we have any code between try and catch blocks?
63.Can we catch more than one excepƟon in single catch block?
64.What are checked ExcepƟons?
65.What are unchecked excepƟons in java?
66.Explain differences between checked and Unchecked excepƟons in java?
67.What is default ExcepƟon handling in java?
68.Explain throw keyword in java?
69.Can we write any code aŌer throw statement?
70.Explain importance of throws keyword in java?
71.Explain the importance of finally over return statement?
72.Explain a situaƟon where finally block will not be executed?
73.Can we use catch statement for checked excepƟons?
74.What are user defined excepƟons?
75.Can we rethrow the same excepƟon from catch handler?
76.Can we nested try statements in java?
77.Explain the importance of throwable class and its methods?
78.Explain when ClassNotFoundExcepƟon will be raised?
79.What is thread in java?
80.Difference between process and thread?
81.What are different types of mulƟtasking?
82.What are the benefits of mulƟthreaded programming?
83.Explain thread in java?
84. List Java API that supports threads?
85.Explain about main thread in java?
86.In how many ways we can create threads in java?
87.Explain creaƟng threads by implemenƟng Runnable class?
88.Explain creaƟng threads by extending Thread class?
89.Which is the best approach for creaƟng thread?
90.Explain the importance of thread scheduler in java?
91.Explain the life cycle of thread?
92.Can we restart a dead thread in java?
93.Can one thread block the other thread?
94.Can we restart a thread already started in java?
95.What happens if we don’t override run method?
96.Can we overload run () method in java?
97.What is a lock or purpose of locks in java?
98.In how many ways we can do synchronizaƟon in java?
99. What are synchronized methods?
100.When do we use synchronized methods in java?
101.When a thread is execuƟng a synchronized method, then is it possible for the
same thread to access other synchronized methods of an object?
102.What are synchronized blocks in java?
103.When do we use synchronized blocks and advantages of using synchronized
blocks?
104.What is class level lock?
105.Can we synchronize staƟc methods in java?
106.Can we use synchronized block for primiƟves?
107.What are thread prioriƟes and importance of thread prioriƟes in java?
108.Explain different types of thread prioriƟes?
109.How to change the priority of thread or how to set priority of thread?
110.If two threads have same priority which thread will be executed first?
111.What all methods are used to prevent thread execuƟon?
112.Explain yield () method in thread class?
113.Is it possible for yielded thread to get chance for its execuƟon again?
114.Explain purpose of sleep () method in java?
115.Assume a thread has lock on it, calling sleep () method on that thread will
release the lock?
116.Can sleep () method causes another thread to sleep?
117.Explain about interthread communicaƟon and how it takes place in java?
118.What is thread local variables?
119.What are daemon threads in java?
120.How to make a non-daemon thread as daemon?
121.Can we make main () thread as daemon?
122.What are nested classes in java?
123.What are inner classes or non-staƟc nested classes in java?
124.Why to use nested classes in java?
(or)
What is the purpose of nested class in java?
125.Explain about staƟc nested classes in java?
126.How to instanƟate staƟc nested classes in java?
127.Explain about method local inner classes or local inner classes in java?
128.Explain about features of local inner class?
129.Explain about anonymous inner classes in java?
130.Explain restricƟons for using anonymous inner classes?
131.Is this valid in java? can we instanƟate interface in java?
132.Explain about member inner classes?
133.How to instanƟate member inner class?
134.How to do encapsulaƟon in Java?
135.What are reference variables in java?
136.Will the compiler create a default constructor if I have a parameterized
constructor in the class?
137.Can we have a method name same as class name in java?
138.Can we override constructors in java?
139.Can StaƟc methods access instance variables in java?
140.How do we access staƟc members in java?
141.Can we override staƟc methods in java?
142.Difference between object and reference?
143.Objects or references which of them gets garbage collected?
144.How many Ɵmes finalize method will be invoked? who invokes finalize ()
method in java?
145.Can we pass objects as an argument in java?
146.Explain wrapper classes in java?
147.Explain about transient variables in java?
148.Can we serialize staƟc variables in java?
149.What is type conversion in java?
150.Explain about AutomaƟc type conversion in java?
151.Explain about narrowing conversion in java?
152.Explain the importance of import keyword in java?
153.Explain naming convenƟons for packages?
154.What is classpath?
155.What is the scope or life Ɵme of instance variables?
156.Explain the scope or life Ɵme of class variables or staƟc variables?
157.Explain scope or life Ɵme of local variables in java?
158.Explain about staƟc imports in java?
159.Can we define staƟc methods inside interface?
160.Define interface in java?
161.What is the purpose of interface?
162.Explain features of interfaces in java?
163.Explain enumeraƟon in java?
164.Explain restricƟons on using enum?
165.Explain about field hiding in java?
166.Explain about Varargs in java?
167.Explain where variables are created in memory?
168.Can we use Switch statement with Strings?
169.In java how do we copy objects?
170.Explain about object-oriented programming and its features?
171.List out benefits of object-oriented programming language?
172.Explain oops concepts in detail?
173.Explain what is encapsulaƟon?
174.What is inheritance?
175.Explain importance of inheritance in java?
176.What is polymorphism in java?
177.What is collecƟons framework?
178.What is collecƟon?
179.Difference between Array and collecƟon?
180.Difference between collecƟon, CollecƟon and CollecƟons in java?
181.Explain about CollecƟon interface in java?
182.List the interfaces which extends collecƟon interface?
183.Explain List interface?
184.List implementaƟons classes of List Interface?
185.Explain about ArrayList?
186.What is vector?
187.Difference between arraylist and vector?
188.Define Linked List and its features with signature?
189.Define Iterator and methods in Iterator?
190.In which order the Iterator iterates over collecƟon?
191.Explain ListIterator and methods in ListIterator?
192.Methods of lisƟterator?
193.Explain about Sets?
194.ImplementaƟons of Set interface?
195.Explain HashSet and its features?
196.Explain Tree Set and its features?
197.When do we use HashSet over TreeSet?
198.What is Linked HashSet and its features?
199.Explain about Map interface in java?
200.What is linked hashmap and its features?
201.What is SortedMap interface?
202.What is Hashtable and explain features of Hashtable?
203.Difference between HashMap and Hashtable?
204.Difference between arraylist and linkedlist?
205.Difference between Comparator and Comparable in java?
206.What is serializaƟon in java?
207.What is the main purpose of serializaƟon in java?
208.What are alternaƟves to java serializaƟon?
209.Explain about serializable interface in java?
210.How to make object serializable in java?
211.Can we serialize staƟc variables in java?
212.When we serialize an object does the serializaƟon mechanism saves its
references too?
213.If we don’t want some of the fields not to serialize How to do that?

You might also like