100% found this document useful (1 vote)
189 views3 pages

Java Interview Questions

The document discusses Java interview questions related to topics like the volatile keyword, transient keyword, difference between marker interface and functional interface, difference between concurrent hash map and hash table, types of memory in JVM, classloader in Java, difference between int and Integer, and more. It provides over 100 questions in total related to Java, Spring, Hibernate, multithreading and other concepts.

Uploaded by

Phyadav
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
100% found this document useful (1 vote)
189 views3 pages

Java Interview Questions

The document discusses Java interview questions related to topics like the volatile keyword, transient keyword, difference between marker interface and functional interface, difference between concurrent hash map and hash table, types of memory in JVM, classloader in Java, difference between int and Integer, and more. It provides over 100 questions in total related to Java, Spring, Hibernate, multithreading and other concepts.

Uploaded by

Phyadav
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 3

Java interview questions

------------------------------------------------------------------------
1.Volatile Keyword in Java.

Ans: Sr. No. Key Volatile


Transient
1 Basic Volatile keyword is used to flush changes
directly to the main memory The transient keyword is used to exclude variable
during serialization
2. Default value Volatile are not initialized with a default
value. During deserialization, transient variables are initialized with a
default value
3 Static Volatile can be used with a static variable.
Transient can not be used with the static keyword
4 Final Volatile can be used with the final keyword
Transient can not be used with the final keyword

Example of Transient
// A sample class that uses transient keyword to
// skip their serialization.
class TransientExample implements Serializable {
transient int age;
// serialize other fields
private String name;
private String address;
// other code
}

Example of Volatile
class VolatileExmaple extends Thread{
boolean volatile isRunning = true;
public void run() {
long count=0;
while (isRunning) {
count++;
}
System.out.println("Thread terminated." + count);
}
public static void main(String[] args) throws InterruptedException {
VolatileExmaple t = new VolatileExmaple();
t.start();
Thread.sleep(2000);
t.isRunning = false;
t.join();
System.out.println("isRunning set to " + t.isRunning);
}
}

2.Difference Between Marker Interface Vs Functional Interface.


3. Difference Between Concurrent hash map and hash table.
4. types of memory in jvm.
5. ClassLoader in Java.
6. difference Between int & Integer.
7. count no of duplicate charactor in string.
8. how to Shorting hashMap key.
9. Component of microservices.
10. joins in sql.
11. get() & load() method in hibernate.
12. Difference Between Controller & RestController
annotation.
13. use of componetScan and autowired annotation.
14. Design pattern in java.
15. MVC architecture in spring.
16. count duplicate value for ArrayList data.
17. find nth highest salary.
18. difference b/w classNotFound exception and
classNotFound error.
19.java code for have id,name and salary print id, name whose salary>10k.
20. @SpringBootApplication annotation.
21. write java code for hashMap.
22. indexing in plSql .
23. Can we overide static & main() method.
24. can we overload main() method.
25. Annotaions for exception handling.
26. How to make Develope a secure API.
27. How to create immutable class in java ?
28. What is singleton class in java ?
29. What is factory design pattern in java ?
30. What is daemon thread in java ?
31. What is garbage collection in java ?
32. What is system.gc() in java ?
33. What is difference between Comparable and Comparator in java ?
34. What is hash code and equal method in java ?
35. Get and load method in hibernate ?
36. how we will reverse the string without inbuild method.
37. Qualifier annotation in java ?
38. put and post in rest api.
39. Java class loader ?
40. what is dependency injection ?
41. what is setter injection and constructor injection in java?
42. what is bean scope ?
43. what is default bean scope ?
44. How to create object in spring ?
45. can we use @Component annotation instead of @Service annotation ?
46. which annotation is introduced in Spring Boot ?
47. why we are using @ComponentScan in java ?
48. what is default port of spring boot ? can we change port of inbuild server ?
49. what is identifier in java ?
50. what is generics in java ?
51. what is annotation part variable ?
52. what is query param?
53. what is list, set and map ?
54. how HashMap internally working in java ?
55. can we do update and delete in HashMap ?
56. what is the by default segment of HashMap ?
57. what is SynchronizedHashMap and ConcurrentHashMap in java ?
58. can we override or over load main method ?
59. what is HashSet and where we need to use this ?
60. Difference between HashTable and HashMap ?
61. how we will convert Array to List ?
62. How to add custom object into collection ?
63. difference between ArrayList and LinkedList?
64. What is HashMap keys and value ?
65. what is inheritance ?
66. what is polymorphism ?
67. what is abstract class ?
68. What is functional interface ?
69. what is lambda expression ?
70. how can we implement functional interface in java ?
71. what is optional in java 1.8 ?
72. what is Thread life cycle ?
73. what is weak HashMap in java ?
74. class and class path in java ?
75. class not found exception v/s No class found error in java ?
76. Type of thread pool in java ?
77. deep cloning vs shallow cloning in java ?
78. clone method and clonable interface in java ?
79. what is Serialization in java ?
80. can we serialize static member ?
81. what are Transient variable ?
82. Example o predefined functional interface ?
83. can we start thread without run method ?
84. difference between instance block and static block ?
85. What is exception handling ?
86. how to create custom exception ?
87. what is diffenence between error and exception ?
88. what is multithreading ?
89. what is process synchronization ?
90. how many types of configurations in spring boot ?
91. what are the core spring framework annotations ?
92. what is Stereotype annotations ?
93. what are springboot annotations ?
94. how to create Rest Api with spring boot ?
95. how we will configure Hibernate with database?
96. what is session factory in hibernate ?
97. what is session in hibernate ?
98. what is first level cache and second level cache in hibernate ?
99. what are the annotations used in hibernate ?
100. what is differnce between get and load in hibernate ?
101. what is the use of @Embeddable in hibernate ?
102. how many synchronizations we are having in java ?
103. what dead lock ?
104. what is thread safe ?
105. where we are using stack and heap memory in java ?
106. why multiple inheritance is not supported in java and how can we achieve
this ?
107. why HashTable is fully synchronized ?
108. what is profiling in springBoot.
109. what is internal implementation of map.
110. How can we handle exception by use of java 8.
111. How to count no repetable no of charactor in String ?
112. What is difference between collection and Collections ?
113. Can we overload and override static method ?

You might also like