• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/20

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

20 Cards in this Set

  • Front
  • Back

Class

-A template or blueprint from which individual objects are created and it defines it's properties and behaviors


-Contains fields & methods to describe the behavior of the object





Object

An instance of a class that has states (data which is stored in fields) and behaviors (methods)



Class/Static Variables

Variables that are a part of the class itself, declared using a special keyword.


There is only one copy and it exists as long as the program runs


When the class is loaded into the computer, there is a section of memory devoted to the class, and that section of memory includes space for the values of the variable

Instance Variables

Non static variables within a class but outside any method.


These variables are instantiated when the class is loaded.


Can be accessed from inside any method, constructor or blocks of that particular class.

Constructor

A special kind of subroutine in a class whose purpose is to create objects belonging to that class.


Is called using the new operator, and is not considered to be a "method."


If not written for the class, then the Java compiler builds a default one.


Can have more than one, convention is to give the same name as the class

Creating an object

Use the class name to create a variable of the class type and instantiate with the New keyword and then call the constructor which initializes the new object


MyClass mc = New MyClass();


The variable holds a reference/pointer to the address of the memory location where the object is stored (the heap)

This

Keyword that is used to refer to the current object.


Typically used in constructor or setter methods to help with readability & understanding so that it is clearly understood that you are using instance variables.


Also used when calling a constructor within another constructor

Inheritance

The fact that one class can extend another. It then inherits the data and behavior of the class that it extends.

Protected

A keyword that is an access modifier for variables/methods of a class.


Allows access


-from within the enclosing class


-only classes in the same package when they instantiate the class


-sub classes, regardless of packages.


Unlike private, which can only be accessed within the class



Polymorphism

Aspect of OOP that allows an object to take on many forms




Examples:


1. Method overriding


2. Method overloading


3. Abstract classes

Interface

Is a reference type, and is thought of as a contract of how a class will behave.


Can contain only constants, method signatures(empty methods), default methods, static methods, and nested types


Cannot be instantiated—they can only be implemented by classes or extended by other of the same



Implementing classes for interfaces

-To use an interface, you write a class that implements the interface.


-it provides a method body for each of the methods declared in the interface.


-Must define all methods stated in the interface - follows the 'contract' specified by the interface

Abstract Classes

-A type of a class that used as base/outline for subclasses.
-Cannot be instantiated
-Allows for some methods to provide functionality and others to just be method signatures

-A type of a class that used as base/outline for subclasses.


-Cannot be instantiated


-Allows for some methods to provide functionality and others to just be method signatures

Abstract VS Interface

Abstract:


-Is a class and consumes more CPU since you have to do look-up when you inherit them


-share code between closely related classes


-Can have defined methods


-members can be defined other than public


Interface:


-Abstract/Reference type


-Empty shell - it's completely up to the implementations to define


-Could be used when unrelated classes


-Mulitple inheritance


-consumes very little CPU as there is no look up to do, just a bunch of names







Tight Coupling

-A class being highly dependent on another class


-How much do changes in class A force changes in class B


-Reduces flexibility in code and makes changes more difficult

Loose Coupling

-Design goal that seeks to reduce the interdepedencies between classes


-Increases flexibility, maintenance, easier to test


-Interfaces are powerful tool to achieve these goals



Inversion of control

-Programming concept where classes should be as independent as possible from other classes


-Classes should not configured its dependencies statically but should be configured from the outside (e.g. not use the new operator, but pass in the object as parameter)

Dependency Injection

-Giving an object its instance variables (dependencies) via passing in through constructor, Setter methods, or specialized framework such as spring


-Useful technique for testing since dependencies can be stubbed/mocked, so class can be tested in isolation

Bean

-A standard/convention in java where a class has 1. all properties private (use getters/setters)


2. A public no argument constructor


3. Implements Serializable



Serializable

-Implements the java.io.Serializable interface


-persistence mechanism used to store objects as a sequence of signed bytes (can be retrieved later by deserialization)


-These classes can be written to streams (files, object databases, sent over network connection, etc)