Core Java Interview Questions with Detailed Answers
5 views 0 purchase
Course
Java
Institution
IIT DELHI
Prepare for your next Java interview with this comprehensive set of Core Java Interview Questions designed to help you ace technical interviews. This PDF contains a curated collection of 100+ frequently asked Java interview questions along with detailed explanations and answers.Key Topics Covered:O...
240 CORE JAVA INTERVIEW
QUESTIONS AND ANSWERS
Table of Contents
1) what are static blocks and static initalizers in Java ? .......................................................... 9
2) How to call one constructor from the other constructor ? ............................................... 9
3) What is method overriding in java ? ........................................................................................ 9
4) What is super keyword in java ? ................................................................................................. 9
5) Difference between method overloading and method overriding in java ? ............... 9
6) Difference between abstract class and interface ? ............................................................ 10
7) Why java is platform independent? ................................................................................... 10
8) What is method overloading in java ? .............................................................................. 10
9) What is difference between c++ and Java ? ................................................................. 10
10) What is JIT compiler ? .............................................................................................................. 10
11) What is bytecode in java ? ................................................................................................. 10
12) Difference between this() and super() in java ? ...................................................... 11
13) What is a class ? .................................................................................................................... 11
14) What is an object ?.................................................................................................................... 11
15)What is method in java ? ............................................................................................................ 11
16) What is encapsulation ? ............................................................................................................ 11
17) Why main() method is public, static and void in java ? ............................................... 12
18) Explain about main() method in java ? .............................................................................. 12
19)What is constructor in java ? ..................................................................................................... 12
20) What is difference between length and length() method in java ? ......................... 12
21) What is ASCII Code? ........................................................................................................... 12
22) What is Unicode ? .................................................................................................................. 13
23) Difference between Character Constant and String Constant in java ? ............ 13
24) What are constants and how to create constants in java? ........................................ 13
25) Difference between ‘>>’ and ‘>>>’ operators in java? .............................................. 13
Core java Interview questions on Coding Standards .................................................................. 13
26) Explain Java Coding Standards for classes or Java coding conventions for
classes? ..................................................................................................................................................... 13
27) Explain Java Coding standards for interfaces? ........................................................... 13
1
, 28) Explain Java Coding standards for Methods? .............................................................. 13
29) Explain Java Coding Standards for variables ? ............................................................... 13
30) Explain Java Coding Standards for Constants? .............................................................. 13
31) Difference between overriding and overloading in java? ....................................... 14
32) What is ‘IS-A ‘ relationship in java? .............................................................................. 14
33) What is ‘HAS A’’ relationship in java? ............................................................................... 14
34) Difference between ‘IS-A’ and ‘HAS-A’ relationship in java? .................................... 14
35) Explain about instanceof operator in java? ....................................................................... 14
36) What does null mean in java? ................................................................................................ 15
37) Can we have multiple classes in single file ? ..................................................................... 15
38) What all access modifiers are allowed for top class ? ................................................... 15
39 ) What are packages in java? .................................................................................................... 15
40) Can we have more than one package statement in source file ? ........................ 15
41) Can we define package statement after import statement in java? ...................... 15
42) What are identifiers in java? ............................................................................................... 15
43) What are access modifiers in java? ................................................................................... 15
44) What is the difference between access specifiers and access modifiers in java? 16
45) What access modifiers can be used for class ? ..................................................... 16
46) Explain what access modifiers can be used for methods? ........................................ 16
47) Explain what access modifiers can be used for variables? ....................................... 16
48) What is final access modifier in java? ...................................................................... 17
49) Explain about abstract classes in java? ................................................................... 17
50) Can we create constructor in abstract class ? ....................................................... 18
51) What are abstract methods in java? ................................................................................. 18
Java Exception Handling Interview questions ................................................................................ 18
52) What is an exception in java? .............................................................................................. 18
53) State some situations where exceptions may arise in java? ................................... 18
54) What is Exception handling in java? ......................................................................... 18
55) What is an eror in Java? ................................................................................................ 18
56) What are advantages of Exception handling in java? ................................................. 18
57) In how many ways we can do exception handling in java? ..................................... 18
58) List out five keywords related to Exception handling ?.............................................. 18
2
, 59) Explain try and catch keywords in java? ................................................................. 19
60) Can we have try block without catch block? .......................................................... 19
61) Can we have multiple catch block for a try block? ...................................................... 19
62) Explain importance of finally block in java? ................................................................... 19
63) Can we have any code between try and catch blocks? .................................................. 19
64) Can we have any code between try and finally blocks? .................................... 19
65) Can we catch more than one exception in single catch block? .................................. 19
66) What are checked Exceptions? ............................................................................................ 20
67) What are unchecked exceptions in java? ........................................................................ 20
68) Explain differences between checked and Unchecked exceptions in java? ........ 20
69) What is default Exception handling in java? .......................................................... 20
70) Explain throw keyword in java? .................................................................................. 21
71) Can we write any code after throw statement? ............................................................ 21
72) Explain importance of throws keyword in java? ........................................................... 21
73) Explain the importance of finally over return statement? ........................................ 21
74) Explain a situation where finally block will not be executed? ......................... 21
75) Can we use catch statement for checked exceptions? ...................................... 21
76) What are user defined exceptions?.................................................................................... 21
77) Can we rethrow the same exception from catch handler? ...................................... 21
78) Can we nested try statements in java? ................................................................................ 22
79) Explain the importance of throwable class and its methods? ......................... 22
80) Explain when ClassNotFoundException will be raised ? .............................................. 22
81) Explain when NoClassDefFoundError will be raised ? .................................................. 22
Java Interview questions on threads ................................................................................................. 22
83) What is process ?...................................................................................................................... 22
84) What is thread in java? .......................................................................................................... 22
85) Difference between process and thread? ........................................................................ 22
86) What is multitasking ? ............................................................................................................ 22
87) What are different types of multitasking? ....................................................................... 22
88) What are the benefits of multithreaded programming? ........................................... 23
89) Explain thread in java? ........................................................................................................... 23
90) List Java API that supports threads?................................................................................. 23
3
, 91) Explain about main thread in java? ....................................................................................... 23
92) In how many ways we can create threads in java? ....................................................... 23
93) Explain creating threads by implementing Runnable class? .................................... 23
94) Explain creating threads by extending Thread class ? ............................................... 23
95) Which is the best approach for creating thread ? ........................................................ 24
96) Explain the importance of thread scheduler in java? ................................................... 24
97) Explain the life cycle of thread? .......................................................................................... 24
98) Can we restart a dead thread in java? ............................................................................. 24
99) Can one thread block the other thread? .......................................................................... 24
100) Can we restart a thread already started in java?..................................................... 24
101) What happens if we don’t override run method ? ........................................................ 24
102) Can we overload run() method in java? ........................................................................ 24
105) What is a lock or purpose of locks in java? .................................................................. 24
106) In how many ways we can do synchronization in java? ......................................... 25
107) What are synchronized methods ? .................................................................................. 25
108) When do we use synchronized methods in java? ......................................................... 25
109) When a thread is executing synchronized methods , then is it possible to
execute other synchronized methods simultaneously by other threads? ...................... 25
110) When a thread is executing a synchronized method , then is it possible for the
same thread to access other synchronized methods of an object ?.................................. 25
111) What are synchronized blocks in java? .............................................................................. 25
112) When do we use synchronized blocks and advantages of using synchronized
blocks? ...................................................................................................................................................... 25
113) What is class level lock ? ......................................................................................................... 26
114) Can we synchronize static methods in java? ................................................................. 26
115) Can we use synchronized block for primitives?............................................................. 26
116) What are thread priorities and importance of thread priorities in java? ............. 26
117) Explain different types of thread priorities ? ............................................................... 26
118) How to change the priority of thread or how to set priority of thread? ............... 26
119) If two threads have same priority which thread will be executed first ?............. 26
120) What all methods are used to prevent thread execution ? ..................................... 26
121) Explain yield() method in thread class ? ........................................................................... 26
122) Is it possible for yielded thread to get chance for its execution again ? ............. 27
4
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller suryateja90149. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.59. You're not tied to anything after your purchase.