Skip to content

Oracle-Exam-Preparation/OCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCP Exam Preparation.

Contents at a Glance.

Oracle Documentations.

About.

  • This project created for educational purposes, and this project may contain invalid or false "Information or Cod Examples".
  • Always check the "Information or Cod Examples" you are learning.

Enum.

Initialization.

Semicolon.

Constructor.

Access Modifier.

Inheritance.

Using "Switch" with "Enum".

Values.

Constructors.

Methods.

Access Modifier.
Abstract.
Non-static.
Static.
Final.

Variables.

Access Modifier.

Non-static.

Static

Final

Methods.

Pre-defined Methods.

Access Modifier.

Abstract

Non-static.

Static

Final

Variables.

Access Modifier.

Non-static.

Static

Final

Note to self.

Nested Class.

  • Exist two types of classes: top-level class, Nested Class.
  • Nested Class divided into two types: "Static Nested Class" and "Inner Class".
  • Sywchestvyet "Anonymous class". "Anonymous class" siempre is "Nested Class" no potom stanovitca libo "Static Nested Class" libo "Inner Class".
  • "Nested Class" may have "access modifier": private, default, protected, public.

Static Nested Class.

Type of Static Nested Class

  • Exist four types of Static Nested Class: interface, abstract class, class, enum.

Inheritance.

Initialization of "Static Nested Class".

Access Modifier of "Static Nested Class".

Constructors.

Access Modifier.

Variables.

Access Modifier.
Non-static.
  • Non-static variables from "top-level class" cannot be used in the "static nested class".
Static.
  • Static variables from "top-level class" can be used in the "static nested class".
Final.

Methods.

Access Modifier.
Abstract.
Non-static.
  • Not allowed definition "static nested class" in the method body.
Static.
  • Not allowed definition "static nested class" in the static method body.
Final.

Note to self.

Local Static Nested Class.

Inner Class.

  • The "Inner Class" has a subtype that name is "Local Inner Class".
  • Ekzempliar "Inner Class" vsehda dolzen sodirzat ssulky na "top-level class".
  • Esli sozdaietsa "top-level class" eto ne znachit chto proisxodit sozdanie "Inner Class".
  • Esli sozdaietsa "Inner Class" to obiazan sywchestvovat ekzempliar "top-level class". I "Inner Class" bydet ssulatsa na "top-level class".
  • Raznue "Inner Class" mohut ssulatsa na odin i totze "top-level class".
  • "Inner Class" mozet bit obiavlion v methode. No znachenie kotoroe vozvrawchaet ethot method ne mozet bit tipos etoho "Inner Class". "Inner Class" kotorui obiavlaetsa v nytri methoda, ne viden za figurnumi scobcami etoho methoda. Znachenie cotoroe vozvrawchaet method mozet bit "Object type" i takim sposobom mozno vozvrawcaht "Inner Class" kororui opredelon v methode.
  • java memory leak. "Inner Class" mozet sprovocurovat "java memory leak". Do toho vremeni kohda ziv "Inner Class" bydet ziv "top-level calss", "Garbage Collector" ne smozet ydalit "top-level class".

Type of Inner Class

  • Exist four types of Inner Class: interface, abstract class, class, enum.

Inheritance.

Initialization of "Inner Class".

Access Modifier of "Inner Class".

Constructors.

Access Modifier.

Variables.

Access Modifier.
Non-static.
Static.
Final.

Methods.

Access Modifier.
Abstract.
Non-static.
Static.
Final.

Note to self.

Local Inner Class.

Type of Local Inner Class

Inheritance.

Access Modifier of "Local Inner Class".

Constructors.

Access Modifier.

Variables.

Access Modifier.
Non-static.
Static.
Final.

Methods.

Access Modifier.
Abstract.
Non-static.
Static.
Final.

Note to self.

Anonymous Class.

Initialization.

Final Class.

Methods.

Variables.

Methods from Object class.

equals.

hashCode.

toString.

getClass.

clone.

Imports.

Static Import.

Casting Values.

Explicit Cast.

Without an Explicit Cast.

Java Inheritance.

  • Virtual Methods in object-oriented programming, a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting class by a function with the same signature to provide the polymorphic behavior.

Class.

Constructor.

Access Modifier.

Variables.

Methods. In other words "Overriding".

Access Modifiers.
Abstract Methods.
Final Methods.
Non-static Methods.
Static Methods.

Interface.

Variables.

Access Modifier.
Static.
Final.

Methods. In other words "Overriding".

Access Modifiers.
Abstract Methods.
Default Methods.
Static Methods.

Abstract Class.

Variables.

Methods. In other words "Overriding".

Access Modifiers.
Abstract Methods.
Final Methods.
Non-static Methods.
Static Methods.

Polymorphism.

  • The dictionary definition of polymorphism refers to a principle in biology in which an organism or species can have many different forms or stages. This principle can also be applied to object-oriented programming and languages like the Java language. Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.
  • Polymorphism is the ability of a single interface to support multiple underlying forms. In Java, this allows multiple types of objects to be passed to a single method or class. In Java, this allows multiple types of objects to be passed to a single method or class.
  • Types of Polymorphism:
    • Inheritance.
    • Generics.


Referenceable Objects and References.

  • We can summarize this principle with the following two rules:
    • The type of the object determines which properties exist within the object in memory.
    • The type of the reference to the object determines which methods and variables are accessible to the Java program.
  • An object is an instance of a class created from it using the new keyword.
  • Classes, interfaces, arrays, enumerations and, annotations are the in Java are reference types in Java. Reference variables hold the objects/values of reference types in Java.

InstanceOf.

Design Principles.

  • A design principle is an established idea or best practice that facilitates the software design process.
  • In general, following good design principles leads to:
    • More logical code
    • Code that is easier to understand
    • Classes that are easier to reuse in other relationships and applications
    • Code that is easier to maintain and that adapts more readily to changes in the application requirements

Encapsulating Data.

Creating JavaBeans.

  • JavaBeans Spec URL

  • JavaBean naming conventions:
    1. Properties are private.
    2. A public no-argument constructor.
    3. Getter for non‐boolean properties begins with "get".
    4. Getters for boolean properties must begin with "is".
    5. Getters for Boolean properties must begin with "get".
    6. Setter methods begin with "set".
    7. The method name must have a prefix of "set", "get", "is" followed by the first letter of the property in uppercase and followed by the rest of the property name.
    8. Implements Serializable.

  • Although boolean values use "is" to start their getter method, the same does not apply to instances of the wrapper Boolean class, which use "get".

  • Example of Java Bean.

Is‐a Relationship.

Has‐a Relationship.

Composing Objects.

Delegation.

Design Pattern.

  • A design pattern is an established general solution to a commonly occurring software development problem. The purpose of a design pattern is to leverage the wealth of knowledge of developers who have come before you in order to solve old problems that you may encounter easily. It also gives developers a common vocabulary in which they can discuss common problems and solutions.

Singleton Pattern.

Lazy Initialization.

Thread Safe.

Singleton and Class Loader.

Immutable Objects.

  1. Use a constructor to set all properties of the object.
  2. Mark all of the instance variables private and final.
  3. Don’t define any setter methods.
  4. Don’t allow referenced mutable objects to be modified or accessed directly.
  5. Prevent methods from being overridden.

Builder Pattern.

Factory Pattern.

Factory Method Pattern.

Functional Interface.

Lambda Expression.

Parameters of Lambda.

Body of Lambda.

Method Reference.

Generics.

Unbounded wildcard.

Lower Bounded Wildcards.

Upper Bounded Wildcards.

Generic Classes.

Generic Nested Classes.

Generic Abstract Class.

Generic Interface.

Generic Function Interface.

Generic Constructor.

Generic Methods.

Collections.

  • For any type of collections, the methods is very important: equals, hashCode, compare, compareTo.

Big O, Big Theta, Big Omega.

Big-O.

Big-Theta.

Big-Omega.

Collections Utils Class.

Methods.

Iterable.

List.

ArrayList.

Constructor.
Methods.
add
set
get
remove
isEmpty
size
clear
contains
indexOf
lastIndexOf
iterator
Initialization.

LinkedList.

  • A LinkedList implements List and Queue.

Old Collections.

Vector.
Stack.
  • If you need a stack, use an ArrayDeque instead

Set.

HashSet

  • A HashSet stores its elements in a hash table. This means that it uses the hashCode() method of the objects to retrieve them more efficiently.
  • The equals() method is used to determine equality.
Constructor.
Methods.
add
remove
isEmpty
size
clear
contains
Initialization.

LinkedHashSet.

TreeSet.

  • A TreeSet stores its elements in a sorted tree structure. The main benefit is that the set is always in sorted order.
  • TreeSet implements the NavigableSet interface. And the interface NavigableSet implemented SortedSet. And the interface SortedSet implemented Set.
Constructor.
Methods.
add
remove
isEmpty
size
clear
contains
lower
floor
ceiling
higher

Map.

Queue.

PriorityQueue.

Constructor.
Methods.
add
remove
isEmpty
size
clear
contains

ArrayDeque.

Constructor.
Methods.
add
remove
isEmpty
size
clear
contains

Heap.

Additional Information.

Method "equals()".

Method "hashCode().

Interfaces "Comparable" and "Comparator". Methods compareTo() and compare().

Concurrent Collections.

Array.

Arrays.

Stream API.

Compiler.

  • Compiler Warning is different from a compiler error in that all of the code still compiles with a compiler error. The compiler warning is Java informing you that you should take a closer look at something.

Help

License

Apache 2.0, see LICENSE.