Core java interview Questions You'll Most Likely Be Asked (Second Edition)


Download 1.52 Mb.
Pdf ko'rish
bet160/171
Sana07.01.2023
Hajmi1.52 Mb.
#1081886
1   ...   156   157   158   159   160   161   162   163   ...   171
Bog'liq
Core JAVA Interview Questions Youll M...

Classes and Methods
Consider the following code snippet:
What will be the output when this code is compiled and
executed?
Can an instance variable be declared as static? Explain.
Explain what happens when the following code is compiled
and executed.
What happens behind the scenes if a constructor is not
explicitly specified?
Explain what happens when the following code is compiled.
What are the possible access specifiers for a constructor?
What will be the output of the following code snippet?
How will you define a constructor? Give an example.
Explain the void keyword with a code sample.
Explain the differences between a constructor and an ordinary
method.
Explain this keyword with a code sample.
Explain the differences between a class and an object.
Explain the new keyword with a code sample.
What will be the output of the following code snippet?
Explain the return keyword with a code sample.


080.
081.
082.
083.
084.
085.
086.
087.
088.
089.
090.
091.
092.
093.
094.
095.
096.
Inner Classes
What is an inner class? What are the different types of inner
classes?
Write a code sample that demonstrates how you can
instantiate an inner class from an outer class.
Write a code sample that demonstrates an Inner Class.
What is “method–local” inner class.
Explain static nested classes with a code sample.
Explain with a code sample how a static nested class can be
instantiated.
Inheritance
Give an example of illegal method overriding.
Explain the super keyword.
The code snippet below has an error. Identity it and state the
reason.
Write a code sample that demonstrates how inheritance can
help in code reuse.
Write a Java code sample that demonstrates method
overriding.
Explain the extends keyword with a code sample.
What will be the output of the following code snippet?
Explain what will be the output of the following code snippet:
What is the output of the following code snippet?
Explain what is the issue with the following code snippet:
Why is dynamin method dispatch?


097.
098.
099.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
Is the following code valid? Explain.
Why does Java not support multiple inheritance?
Explain with a code sample how you can prevent a method
from being overridden.
The code below has an error. Identify it and state how it can
be fixed.

Download 1.52 Mb.

Do'stlaringiz bilan baham:
1   ...   156   157   158   159   160   161   162   163   ...   171




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling