java training in chennai - PowerPoint PPT Presentation

About This Presentation
Title:

java training in chennai

Description:

Besant Technogies Provide Java Training in Chennai along with 100% Placements assistance. Awarded as the Best Java Training Institute in Chennai. – PowerPoint PPT presentation

Number of Views:22
Slides: 12
Provided by: sasitmail

less

Transcript and Presenter's Notes

Title: java training in chennai


1
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • https//www.besanttechnologies.com/training-course
    s/java-training

2
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • The encapsulation in Java or the object-oriented
    programming language is a concept that imposes
    the protection of variables,
  • functions outside the class, in order to better
    manage this piece of code and have less impact or
    no impact on other parts of a program due to the
    change in the protected code.
  • The encapsulation in Java is visible in
    different places and the Java language itself
    provides many constructions to encapsulate the
    members.

3
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • You can completely encapsulate a member, either
    a variable or a method in Java using a private
    keyword,
  • and you can even get a lower degree of Java
    encapsulation using other access modifiers, such
    as protected or public.
  • The true value of the encapsulation is perceived
    in an environment that is prone to change a lot
    and we know that in the software requirements
    change every day at that time,
  • if you have your code well encapsulated, you can
    better manage the risk with a change of
    requirement .

4
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • Along with the Java abstraction and polymorphism
    in Java, the encapsulation is one you must know
    the concept.
  • In this Java tutorial,
  • we will look at how to use Java encapsulation,
  • the advantage and disadvantage of encapsulation
    and various design patterns and real-life
    problems that make use of the object-oriented
    Encapsulation concept.

5
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • If you are looking for a guide Quick on the
    principle of OOPS and SOLID design in Java,
  • then you can find 10 principles of
    object-oriented design that the Java programmer
    should know in an interesting way. What is Java
    encapsulation
  • Encapsulation is nothing more than protecting
    anything that is prone to change. The rational
    behind the encapsulation is that if any
    functionality is well encapsulated in the code,
  • that is, it stays in one place and does not
    extend around the code, it is easy to change.
    This can be best explained with a simple example
    of encapsulation in Java.

6
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • We all know that the constructor is used to
    creating objects in Java and the constructor can
    accept an argument. Suppose we have a class Loan
    has a constructor and then, in several classes,
  • it has created an instance of the loan using
    this constructor. Now, the requirements change
    and you need to include the borrower's age, as
    well as take a loan. Since this code is not well
    encapsulated, that is, not confined in one place,
    you need to change anywhere you are calling that
    builder, or for a change it is necessary to
    modify several files instead of just one file
    that is more prone to errors and tedious.

7
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • Although this can be done with the refactoring
    feature of the advanced IDE, it would not be
    better if you only need to make changes in one
    place ? Yes, this is possible if you encapsulate
    the Loan creation logic in a method, as
    createLoan () says and the client code calls this
    method and this method internally creates the
    Loan object.
  • In that case, you only have to modify this method
    instead of all the client code.

8
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • Valving encapsulation in Java and OOPS Here are
    some advantages of using Encapsulation when
    writing Java code or in any object-oriented
    programming language 1. Encapsulated code is
    more flexible and easy to change with new
    requirements.2.
  • Java encapsulation facilitates unit testing.3.

9
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • The encapsulation in Java allows controlling who
    can access what. Encapsulation also helps to
    write the immutable class in Java, which is a
    good choice in multi-threading environment. The
    encapsulation reduces the coupling of modules and
    increases the cohesion within a module, because
    all the pieces of a thing encapsulated in a
    single place.6. The encapsulation allows you to
    change a part of the code without affecting other
    parts of the code.
  • What you should encapsulate in the code All that
    you can change and more likely to change in the
    near future is an encapsulation candidate.

10
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • This also helps to write more specific and
    cohesive code. An example of this is the object
    creation code, code that can be improved in the
    future,
  • such as classification and search logic.

11
WHAT IS THE ENCAPSULATION IN JAVA AND OOPS
  • Design template based on Java encapsulationMuitos
    standard design in Java uses the concept of
    encapsulation,
  • one of them is the factory default that is used
    to create objects.
Write a Comment
User Comments (0)
About PowerShow.com