0% found this document useful (0 votes)
2 views7 pages

Core Java Interview Questions Guide

The document contains a comprehensive list of Core Java interview questions categorized into various topics such as Basic Concepts, Structure of Java Program, Data Types, Variables, Type Casting, Methods, Object-Oriented Programming, Constructors, and Encapsulation. Each section includes multiple questions aimed at assessing knowledge and understanding of Java programming concepts. It also provides insights into Java Beans and POJOs, highlighting their characteristics and differences.

Uploaded by

Himanshu kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Core Java Interview Questions Guide

The document contains a comprehensive list of Core Java interview questions categorized into various topics such as Basic Concepts, Structure of Java Program, Data Types, Variables, Type Casting, Methods, Object-Oriented Programming, Constructors, and Encapsulation. Each section includes multiple questions aimed at assessing knowledge and understanding of Java programming concepts. It also provides insights into Java Beans and POJOs, highlighting their characteristics and differences.

Uploaded by

Himanshu kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

QSpiders|JSpiders|PySpiders, NOIDA

B-4, Block-B, Sector-3, Noida


Core Java Interview Questions by Shambhu Sir
Friday, 26 September 2025 @kumarsam07
@javac_java

➢ Basic Concept:
1. Explain difference between procedure oriented and object-oriented
programming?
2. Explain difference between compiler and interpreter.
3. What are the four pillars of object-oriented programming?
4. Define all four pillars such as Encapsulation, Inheritance, Polymorphism and
Abstraction.
5. How java is a platform independent language?
6. What is Byte Code/magical code in java?
7. Explain the working of JVM?
8. What are the types of Error?
9. Explain compile time error and Run time Error.
10. Explain what is exception?
11. What is exception handling?

➢ Structure of Java Program:


12. What will happen if a java program doesn’t have main method?
13. What are keywords? Mention few of them.
14. How many keywords are used in main method of java?
15. What are identifiers? Tell me all its rules.
16. What is difference between keywords and identifiers?
17. Why String[] args is used in main method of java? What is its use?
18. Explain command line argument feature.
19. What will happen if a program has multiple method?
20. What will happen if there are multiple main method inside a program with
different arguments?

QSpiders| JSpiders Shambhu Kumar


➢ Data Types:
21. Explain data types. Why it is used?
22. How many data types are in java? Explain them.
23. Mention at least 5 differences between primitive and non-primitive data.
24. Represent byte a=100; in memory representation of 2’s compliment.
25. Represent byte a=80; in memory representation of 2’s compliment.
26. Represent byte a=-120; in memory representation of 2’s compliment.
27. Represent byte a=-28; in memory representation of 2’s compliment.
28. Design a non-primitive data for Employ with some attributes and show how to use
it.
29. Design a non-primitive data for Product with some attributes and show how to
use it.
30. Design a non-primitive data for Vehicle with some attributes and show how to use
it.
31. Why java is called strictly typed programming language.

➢ Variable:
32. What is a variable? Why it is used?
33. What are different types of variables?
34. Explain local, static and non-static variables? How it is accessed in java program?
35. What is default value of a local variable?
36. What is scope of a local variable?
37. What is scope of a static variable?
38. What is scope of a non-static variable?
39. Can we have default value for a static or non-static variable?
40. Can we have a local variable and global (static or non-static) variable with the
same name? if so, then which variable gets preference?
41. Explain what is variable shadowing?

➢ Type casting:
42. What is primitive type casting?
43. Explain widening and narrowing?
44. Explain implicit and explicit conversion.
45. Why widening is called implicit conversion and narrowing is called explicit
conversion?

QSpiders| JSpiders Shambhu Kumar


Methods:
46. What is method? Why it is used?
47. How many methods can be designed inside a class?
48. How method is executed?
49. In which memory area method execution takes place?
50. Which mechanism is followed in method execution?
51. How we can call and execute a static type method?
52. How we can call and execute a non-static type method?
53. What is the main advantage of a method?
➔Code Reusability
54. Why main method of java should be always declared as public?
55. Why main method should be always declared as static?
56. Why main method return type is always void?
57. What is the purpose of String[] args in main method?
58. If there are multiple methods inside a class along with main method then which
method will be executed?
59. If there are multiple methods inside a class without main method then which
method will be executed?
60. If there are multiple main methods inside a class with main(String[] args),
main(String args) and main(int args) method then which method will be
executed?
61. If there are multiple main methods inside a class with main(String args), main(int
args) and main(int[] args) method then which method will be executed?
62. What are the types of methods?
63. Which method can be used to transfer values from one method frame to another
method frame?
64. What value is returned from a method with return type void?
65. How many values can we return from a method?
66. Which type of method can be directly called inside [Link]()?
67. How many access modifiers can be used in declaration of a method?
68. How many non-access modifiers can be used in declaration of a method?
69. Can we use static and abstract keyword together?
➔No, it forms illegal combination

QSpiders| JSpiders Shambhu Kumar


➢ OOP Programming:
70. What is Object Oriented programming? Why it is used?
71. What are the four pillars of OOP?
72. Is java a 100% object-oriented language? Explain.
73. What is class and object? Define it.
74. What are the properties of a class?
75. Explain new keyword.
76. Explain how object is created in java?
77. What is the work of constructor?
78. What are reference data type? What is its default value?
79. Explain reference variable? What is its default value?
80. What do you mean by instantiation?
81. What is instance?
82. Explain static type members?
83. What is the main purpose of static members?
84. How many copies of static members are loaded in a program execution?
85. Why main method is always static?
86. Explain non-static members?
87. What is the main purpose of non-static members?
88. How many copies of non-static members are loaded in a program execution?
89. What are class members?
90. What are instance members?
91. Why non-static members are called instance members?
92. What is the different memory block are created by JVM at run time. Explain them.
93. Explain the difference between Stack and Heap Area?
94. Explain static and non-static block or what is static or non-static initializer block?
95. Can we run a java program without main method?
96. Which type members can be accessed directly inside a static method?
97. Which type members can be accessed directly inside a non-static method?
98. Can we access a static member directly inside static block?
99. Can we access a non-static member directly inside non-static block?
100. Can we access a static member directly inside non-static block?
101. Can we access a non-static member directly inside a static block?
102. Explain variable shadowing?
103. How variable shadowing is resolved in case of static variables?
104. How variable shadowing is resolved in case of non-static variables?
105. Explain this keyword?
106. What will be inside this keyword? OR, what does this keyword contain?
//It contains the reference of the current object under execution

QSpiders| JSpiders Shambhu Kumar


Constructor:
107. What is constructor? What is its use?
108. Explain the difference between method and constructor?
OR, how does a constructor differ from a method?
109. What is the return type of a constructor?
110. Can a constructor be static or final?
111. What are the different types of constructors?
112. Explain default constructor with its use?
113. Explain parameterized constructor? What is its use?
114. How a constructor is called?
115. Explain constructor overloading with its use?
116. What is the advantage of constructor overloading?
117. Explain “Boilerplate code”.
➔A set of code which is repeatedly being used with little or no
change
118. Explain constructor chaining with its use?
119. What is the advantage of constructor chaining?
120. Explain this() statement.
121. How many constructors can be called by one constructor?
122. Can we make this() as the second statement?
123. Can a constructor call a method?
➔Yes
124. Can we use this() call inside a method?
➔NO
125. What are the restrictions on constructors?
126. Explain copy constructor with a program. What is its use?

Encapsulation:
127. What is encapsulation?
128. What is data binding?
129. How we can achieve encapsulation?
130. Explain setters() and getters() method.
131. What is mutator and accessor method?

QSpiders| JSpiders Shambhu Kumar


132. What is data hiding?
133. If we have to design a class and we need to set the details only
after validation, then which concept we should use?
134. Design one program to demonstrate encapsulation.
135. What are the advantages of Encapsulation?
136. What are the disadvantages of Encapsulation?
➔It leads to Boiler Plate code
137. What is a POJO (Plain Old Java Object)?

A POJO (Plain Old Java Object) is a simple, lightweight Java class that:
• Does not depend on any specific framework, technology, or external
restrictions (like EJB, JPA, Spring).
• Primarily holds data and may have simple behavior (getters, setters,
toString, etc.).
• Is not bound by special naming conventions, annotations, or inheritance
rules.
It’s basically a normal Java object used to represent data in a clean,
reusable, and flexible way.

Key Characteristics of a POJO


A POJO:
• Does not extend or implement any framework-specific class or interface.
• Uses private fields for encapsulation.
• Provides public getters and setters to access or modify data.
• May contain constructors, toString(), equals(), and hashCode().
• Has no heavy annotations or business logic.

In Short:
A POJO is just a plain, simple Java class with private fields, public
getters/setters, constructors, and no special framework dependencies, used
mainly for holding and transferring data.

QSpiders| JSpiders Shambhu Kumar


138. What is a Java Bean class? How is it different from a POJO? What
are its advantages?
A Java Bean is a special type of POJO that follows specific conventions defined by
the JavaBeans specification.
JavaBeans are commonly used for encapsulation, data transfer, and working
with frameworks (like JSP, Spring, Hibernate, etc.) that rely on this standardized
structure.
Rules for a Java Bean Class
A class is considered a Java Bean if it follows these rules:
1. Private Fields: All instance variables must be private.
2. Public Getters and Setters: To access and modify fields.
3. Public No-Arg Constructor: Allows easy instantiation.
4. Serializable (Optional but Recommended): Should implement
Serializable for object persistence and transfer across networks or files.

QSpiders| JSpiders Shambhu Kumar

You might also like