Core Java Interview Questions.doc
Core Java Interview Questions.doc
1
21. What is inheritance and explain types of inheritance?
22. What is constructor?
23. How many types of constructors are there and explain?
24. Can we call explicitly constructor?
25. How can we call from default constructor parameterized constructor?
26. Does a class inherit the constructor of its super class?
27. Can we make constructor static?
28. Can we make final keyword before constructor?
29. What is the difference between constructor and method?
30. What is hash code?
2
48.Is it possible to compile and run a java program without writing main
method()?
49.How objects are passed to methods in java?
50.What is the use of this(),this(..) keywords?
51.What is the use of super(),super(..) keywords?
52.What is the difference between this() and super() keywords?
53.Can we override private methods?
54.Can we take private methods and final methods as same?
55.What is final?
56.How to prevent method overriding?
57.How to prevent inheritance in java?
58.What is mean by shadowing?
59.Can we possible to override the static methods?
60.What is static block and explain?
61.What is instance block and explain?
62.What is difference between instance block and static block?
63.Incorporating more than one constructor in a class is called?
64.What is specialization and generalization?
65.What is implicit casting?
66.What is explicit casting?
67.Can we call class as a data type?
68.What happens if main() method is written without String args[ ] ?
69.Can you call the main() of a class from another class?
70.What are the modifiers in java?
71.What is abstract method?
72.What is abstract class?
73.Abstract classes can contain abstract methods?
74.Explain about transient modifier?
75.Explain about native modifier?
3
76.Explain about volatile modifier?
77.What is mean by synchronisation?
78.Why would you use a synchronized block verses synchronized method?
79.What is interface?
80.Can you write an interface without any methods?
81.What do you call the interface without any members?
82.How can you force your programmer to implement only the features of
your class?
83.Can we declare a class as abstract and final?
84.Can we override abstract methods?
85.Can we implement one interface from another?
86.Why the method of interfaces are public and abstract by default?
87.Can we write a class with in an interface?
88.What is the difference between an interface and an abstract class?
89.Can we create an object to interface?
90.When we go for abstract and interface in java?
91.Why we use interfaces?
92.What is the difference between a class and an abstract class?
93.What is the difference between an interface and an abstract class?
94.What is class loader and explain types of class loaders?
95.Explain about system class loader?
96.Explain Annotations in java?
97.Explain about memory management in java?
98.Is String a class or data type?
99. String s = “ pooji ” ;
String s1 = new String(“ pooji”);
System.out.println(s=s1);
System.out.println(s.equals(s1));
What is the output?
4
100. What is object reference?
101. What is the difference between == and equals() while comparing
String? Which one is reliable?
102. What is string constant pool?
103. Why overrides equals() and hashcode()?
104. What is difference between String and StringBuffer classes?
105. What is main different between StringBuffer and StringBuilder
classes?
106. What is an Error?
107. Write an exception hierarchy?
108. What is an Exception?
109. What is the difference between error and an Exception?
110. What is mean by Exception handling?
111. What are the types of Exceptions?
112. What is throwable?
113. What is the super class for all Exceptions?
114. What is the difference between throws and throw?
115. Is it possible to re-throw exceptions?
116. What is the purpose of finally block?
117. What is the purpose of finalization?
118. Explain final, finally, finalization?
119. If i write system.exit(0); at the end of the try block, will the finally
block will execute?
120. If i write return at the end of try block, will the finally block will
execute?
121. How to create user defined exceptions?
122. How to override methods in exception handling?
123. Can a top level class be private or protected?
5
124. What is the default value of an object reference declared as an
instance variable
125. Is it necessary that each try block must be fallowed by a catch
block?
126. What is fail fast exception?
127. How can you call the garbage collector?
128. What is the scope of default access specifier?
129. What is the difference between return and system.exit(0)?
130. What is difference between System.exit(0) and system.exit(1);
131. Write collection hierarchy?
132. What are limitations of object Arrays?
133. What are differences between arrays and collections?
134. What is Collection API ?
6
150. What is difference between ArrayList and Vector?
151. How we can get synchronized version of ArrayList?
152. What is difference between size and capacity of a Collection
Object?
153. What is difference between ArrayList and Linked List?
154. What are legacy classes and interfaces present in Collections
framework?
155. What is difference Enumeration and Iterator?
156. What are limitations of Enumeration?
157. What is difference between enum and Enumeration?
158. What is difference between Iterator and ListIterator?
159. What is relation between ListIterator and Iterator?
7
175. What is IdentityHashMap?
176. What is TreeMap?
177. What is Hashtable?
8
201. What is difference between shallow copy and deep copy?