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


Explain how Java achieves abstraction


Download 1.52 Mb.
Pdf ko'rish
bet9/171
Sana07.01.2023
Hajmi1.52 Mb.
#1081886
1   ...   5   6   7   8   9   10   11   12   ...   171
Bog'liq
Core JAVA Interview Questions Youll M...

Explain how Java achieves abstraction.
Answer:
Abstraction is an OOPs concept whereby only the necessary
information is exposed to the end user and the internal
implementation details are hidden. Java achieves abstraction via
abstract classes and interfaces. So, you can declare the methods
that you want to be exposed to the outside world in an abstract
class or interface. The actual implementation will be within
concrete classes that extend the abstract classes or implement
the interfaces. The outside code is not aware of the implementing
classes, they interact with your code via the interfaces or abstract
classes.



011.
a.
b.
012.
a.
b.
c.
d.
e.
CHAPTER
02
Java Basics
What are the possible ways of declaring the Java main
method?
Answer:
Following are the possible ways of declaring the Java main
method.
public static void main (String argument [])
static public void main (String argument [])
So, while declaring the Java main method, the order of the public,
static, void keyword does not matter, they can be written in any
order.
What are the possible ways of declaring a Java class?
Answer:
Following are the possible ways of declaring a Java class:
public class Class1 {}
class Class2 {}
private class Class3 {}
protected class Class4 {}
static class Class5{}
Approach a declares a class as public. Approach b does not
use any access specifier, so it has default access. It will be
accessible only within the package. Approaches c and d use the



Download 1.52 Mb.

Do'stlaringiz bilan baham:
1   ...   5   6   7   8   9   10   11   12   ...   171




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