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

Packages
Classes and other resources are organized into folders with unique namespaces
called packages. Packages are commonly organized by two competing
methodologies: package-by-layer and package-by-feature.
A package-by-layer strategy groups classes together according to their layer
in an application. For example, a package-by-layer structure might include
a model, controller, service, dao, and utility package. Package-by-layer works
for small applications, but it doesn’t scale well due to the large number of tightly
coupled classes that span a relatively small number of packages.
A package-by-feature strategy groups classes together according to their
cohesiveness in an application. For example, a package-by-feature structure
might include a customer, order, product, review, and report package. Package-
by-feature encourages high modularity and loose coupling and is preferable
to package-by-layer.


Questions
What is the difference between a class and an object?
What happens when an object is instantiated for the first time?
What is the difference between a primitive type and an object?
What is the difference between autoboxing and unboxing?
What is an array?
How is a String different from a regular object?
What is the difference between a StringBuilder and a StringBuffer?
Why are enums superior to String or Integer constants?
What is the difference between package-by-layer and package-by-feature?


Object-Oriented Programming
(Part II)
Methods
Methods contain the logic that provide an object with behavior. A method
declaration contains a list of modifiers, a return type, a method name, a list
of parameter types and their corresponding names, and a list of throwable
exceptions. A method signature is the combination of the method name as well
as the types and order of its parameters. Note that the names of parameters are
not included in the method signature.
A method can invoke itself in a process called recursion. Recursion is an
alternative to looping that provides an elegant solution for problems that
naturally repeat, such as mathematical sequences or divide and conquer
algorithms. A recursive method must have a termination condition that
determines when the method stops calling itself and starts returning values
to previous invocations on the call stack. A recursive method with
no termination condition will eventually cause a StackOverflowError.



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