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ə4/47
tarix06.05.2023
ölçüsü0,53 Mb.
#108601
1   2   3   4   5   6   7   8   9   ...   47
Java Interview Guide

Coupling
Coupling refers to the level of dependency that exists between two entities.
For example, a cell phone battery that is soldered to a motherboard is tightly
coupled because neither the battery nor the motherboard can be replaced without
affecting the other component. A battery that snaps into the back of a phone
is loosely coupled because both entities could be replaced independently.
In software applications, decoupled components are more flexible and easier
to maintain.


Cohesion
Cohesion refers to an entity’s level of focus. For example, a Swiss Army knife
is a low cohesion entity because it can do multiple things, but it can’t do them
very well. A multi-tool could never match the productivity of a toolbox filled
with highly cohesive tools. In software applications, cohesive components are
more robust and easier to test.


Questions
What is the purpose of abstraction in software development?
What is encapsulation? How does Java support it?
What is polymorphism? How does Java support it?
What is the difference between a mutable object and an immutable object?
How can you design an object to be immutable?
What is the difference between coupling and cohesion?
What is the preferred relationship between software components and why?


Object-Oriented Programming
(Part I)
Classes & Objects
Java objects are built from a blueprint called a class. A class defines the name
of an object, what type of state the object has in the form of fields, and what kind
of behavior the object has in the form of methods.
When an object is instantiated with the new keyword, the class file and all of its
superclasses are loaded into the JVM by the system class loader. After the one-
time initialization of the class, the object is initialized by invoking a special
method called a constructor. A constructor performs initialization logic after
recursively invoking all of the constructors of its superclasses. Superclasses must
be initialized before subclasses in case a child object relies on functionality from
a parent.



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