Unit 1 Flashcards
Abstraction
Programming definition: “abstraction is the process of determining the set of features ( properties and methods) that a class will have”
Fundamental concepts of objects
1) an object is some computer code that occupies space in memory
2) the object has two main parts
its properties(data)
and it’s methods(named blocks of code that do something when they are called)
True or false: Everything in Java is an object.
False the eight primitive data types are not… they do not have any methods attached to them.
define class in java
a collection of code that contains the instructions for building an object of that class in memory aka the blueprint for creating an object
When does an object get built in memory?
when the constructor method of the class file is called and executed
class vs object analogy
follow the recipe (the class) for chocolate chip cookies and the objects are the cookies that come out of the oven.
What are the three pillars of OOP?
1) Encapsulation
2) Inheritance
3) Polymorphism
Basic concept of encapsulation:
Access to the data and methods of a class can be controlled using the visibility modifiers public, protected and private
Basic idea of encapsulation is about being able to control access to an object’s properties and methods.
Inheritance
a sub-class (or child class) can inherit methods from its super class (or parent class) i.e it can make use of code written in the parent class without having that code written in its own class. This means that we only need to write the method once in a parent or super class. (Yay! Less code to write!) Sub-classes or child classes that are derived or extended from the super class can inherit the method from the super class. Thus, they can call the method from the parent class. In Java, every class we write inherits some methods and properties from the Object class, which Java provides for us. The Object class is often called “the mother of all classes”.
Polymorphism aka late binding or dynamic binding
you can have several methods with the same name defined in different classes of a class hierarchy. This is called method over-riding, as opposed to method overloading. These are different concepts
If an object invokes a method, the actual method that runs depends on the class of the object that made the method call. The JVM determines this while the program is running. The JVM will ask “OK, what is the class of the object that just called this method?” When it determines that it was an object of, say, class MyWidget, then the JVM will run the method that is defined in the MyWidget class.
Classes
a class file is used to describe entities that have similar properties or attributes. similar to data modeling done in DB work. A customer class would describe the attributes and methods of customer objects.
In programing, think of a class as a ____ or ____ or ____ that defines the attributes and methods of objects of the same type. (T!)
description
blueprint
recipe
Object: an object is a particular ____ of a class. (T!)
instance
In java coding, we can think of an object as a collection of code that contains two things(T!):
1) some data in variables (aka properties, such as customer ID number)
2) some methods that can manipulate the data held in the variables.
An object ____ both the data and the methods of the object in the block of memory assigned to hold the object. (T!)
holds
Analogy: a single chocolate chip cookie is an object of the ChocolateChipCookie class.
The data held in an object is also sometimes referred to as the ____ of the object. (T!)
state
The state of an object is represented by the _______
values held in it’s data variables.
True or false: An objects state can change.
True if the variables values are modified.