Java Interview Guide: How to Build Confidence With a Solid Understanding of Core Java Principles pdfdrive com



Yüklə 0,53 Mb.
Pdf görüntüsü
səhifə3/47
tarix06.05.2023
ölçüsü0,53 Mb.
#108601
1   2   3   4   5   6   7   8   9   ...   47
Java Interview Guide

Object-Oriented Concepts
Abstraction
Abstraction is the act of perceiving an entity from a narrow perspective.
For example, in the context of education a person can be reduced to a student,
and in the context of employment a person can be reduced to an employee.
Each abstraction reduces the attributes of a person to a subset of relevant
information. The goal of abstraction is to reduce complexity in software systems.


Encapsulation
Encapsulation is a technique that encourages abstraction by purposefully hiding
information. For example, the mechanical details of a car engine are
encapsulated behind a steering wheel and floor pedals. Anyone familiar with this
interface could drive a car without knowing what type of engine was under the
hood. Java encourages encapsulation through the use of interfaces and
by providing access modifiers that limit the visibility of classes, fields,
and methods.


Polymorphism
Polymorphism is a technique that encourages abstraction by allowing an entity
to assume multiple forms. For example, a smartphone is polymorphic because
it can assume the role of a camera, web browser, music player, or digital clock.
Each application exposes a relevant interface to the user. In Java, an object can
take on the form of any parent in its hierarchy or any interface in its hierarchy.


Mutability
Mutability refers to the ability of an entity to change its state. An iPod is an
example of a mutable entity because its contents frequently change. A vinyl
record is an example of an immutable entity because its contents are
permanently engraved. Immutable objects provide numerous benefits in software
applications, such as stability and thread safety. Strings and all of the
primitive wrapper objects are examples of immutable objects. In order to make
an object immutable, the class must be final, all fields must be final, and it
cannot expose any mutable fields or methods that modify mutable fields.



Yüklə 0,53 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9   ...   47




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin