0% found this document useful (0 votes)
5 views2 pages

OOP Terms

The document is a glossary of Object-Oriented Programming (OOP) terms in Java, defining key concepts such as access modifiers, classes, objects, fields, constructors, methods, and various types of methods. It also covers additional terms related to Java programming, including packages, projects, refactoring, and the Java Virtual Machine (JVM). The document outlines the sequence for programming in Java, detailing steps for creating user-defined classes and applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

OOP Terms

The document is a glossary of Object-Oriented Programming (OOP) terms in Java, defining key concepts such as access modifiers, classes, objects, fields, constructors, methods, and various types of methods. It also covers additional terms related to Java programming, including packages, projects, refactoring, and the Java Virtual Machine (JVM). The document outlines the sequence for programming in Java, detailing steps for creating user-defined classes and applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Glossary of Terms - OOP

Access Modifier Reserved words “public”, “private”, “protected” in Java. Control whether classes and members may be
accessed from any class, only this class, subclasses.
- private = can only be accessed from this class
+ public = can be accessed from any class
# protected = can be accessed from any class in the same package
Class Main building block in Java. Contains members, including fields and methods. Classes are the “blueprint”
for creating objects.
Object An instance of a class. For example, Person could be a class, and a person (e.g. person1) would be an
object created using the class. In other words, person1 is an object of type Person or an instance of Person.
Field Member in a class that holds data (e.g., name, age, etc.). Usually marked private so that other programs
cannot directly access it.
private String name;
private int age;
Constructor Special block of code used to create an instance of a class (or, if you prefer, an object whose type is the
class). Used with the “new” keyword.
Default constructor: Parameterised constructor:
Receives no parameters. Programmer decides Receives values for the fields as parameters and
which values to give to the fields. save these values into the fields:
In the class: In the class:
public Person() public Person(String n, int a)
{ {
name = “anonymous”; name = n;
age =18; age = a;
} }
Using constructor to instantiate an object: Using constructor to instantiate an object:
Person person1 = new Person(); Person person1 = new Person(name, age);
NB: this person will then have the default name
and age.
Method Member in a class that does some processing
(e.g., like a subroutine or function or procedure in other languages).
Method Parameters refer to the list of variables in a method declaration. Arguments are the actual values that are
Argument, passed in when the method is invoked. When you invoke a method, the arguments used must match the
Method declaration's parameters in type and order.
Parameter
Typed method For example, in the method
(returns a public int calcBirthYear(int currentYear)
value of a {
specific type) int year = currentYear – age;
return year;
}
“currentYear” is the parameter for this method. The “year” is a local variable (only used in this method)
and “age” a field. The method states that an integer will be returned, so the method returns the calculated
method.
This method is used as follows:
int year = person1.calcBirthYear(2012);
“2012” is the argument of the method and it must match the type of the method’s parameter.
Void method For example, in the method
(a method that public void increaseAge(){
does not age = age+1;
return }
anything This method has no parameters. It returns nothing. It changes the field “age” and saves it back into the
field.
This method is used as follows:
int year = person1.calcBirthYear(2012);
“2012” is the argument of the method and it must match the type of the method’s parameter.
Mutator For example, in the method
method public void setName(String name)
(Also called a {
setter. this.name = name;
Receives the }
value of a The “name” is the parameter for this method that gets saved into the field name. Because the parameter
variable in a and the field have the same name, we use this.name to indicate which one is the field.
parameter and This method is used as follows:
saves it to the person1.setName(“Fred”);
field.) “Fred” is the argument of the method and it must match the type of the method’s parameter.
Accessor For example, in the method
method public String getName()
(Typed {
method that return name;
returns the }
value of the This method is used as follows:
field) System.out.println(person1.getName());
Overload To provide multiple methods with the same name but different parameters (i.e., same name but different
(Method) signatures).
Override When a subclass implements a method inherited from the super class, this method is said to be overridden.
(Method) Example: toString method exists as part of the structure of every class. When you make your own toString
method you overwrite the original toString method
Other terms
Package Packages are imported into a source file to save typing the full name of the class (e.g., can say “Person”
instead of “org.eclipsetraining.librarytutorial.Person” and to avoid the possibility of two classes having
identical names.
Project In Eclipse, a way to organize your work. An Eclipse workspace can contain multiple projects. Each
project can contain multiple packages. Each package can contain multiple classes.
Refactor To improve a program without changing the way it works (i.e., its API). Examples include renaming fields
or variables, streamlining code, etc. Very important in agile development because of emphasis on self-
documenting code.
Reference In Java, variable that holds an object reference (e.g., p = new Person();). Points to an area on the “heap”
Variable where the object resides. Contrast with value variable.
Static Method A method that belongs to the entire class instead of one instance of the class. Invoked with
<Class>.<Method> (e.g., Person.getTotalCount()). Used for methods that doesn’t rely on any one instance
of a class.
Swing A set of standard Java packages that implement a graphical user interface without using any “native” code.
Type In Java, an attribute of a variable to indicate either a primitive type (int, boolean, etc.) or class
membership. For objects, the type is the class to which it belongs. Types also include interfaces and
enumerations.
Value Variable Variable that holds the value of a Java primitive (e.g., integer, character, etc.). Held in the memory stack.
Contrast with reference variable.
Workspace Top-level container for Eclipse work. Holds multiple projects. In a single Eclipse session, only one
workspace can be active.
API (Application The way one program uses another program. In Java, the API can be thought of as the collection of public
Programming methods for a class or package.
Interface)
IDE (Integrated Program, like Eclipse, that provides the different tools required to develop a software package.
Development
Environment)
JVM (Java The program that runs Java programs on a specific platform. Java source code is compiled into .class files.
Virtual Machine) These contain the instructions used by the JVM to actually run the programs on a Windows PC, a Linux
(also known as computer, a Mac computer, etc. The JVM is written for each platform supported by Java
Java Runtime
Engine or JRE)

Sequence to program:
1. Make your user-defined class (the one without the main method)
1.1. Make your fields
1.2. Make your mutator and accessor methods
1.3. Make your constructor (between the fields and the mutator and accessor methods)
1.4. Make the other methods
2. Make your application (the class with the main method)
2.1. If you use a default constructor:
2.1.1. Instantiate an object of the class
2.1.2. Get input
2.1.3. Use the mutator methods to get the values into the other class
2.1.4. Use the other methods
2.2. If you use a parameterised constructor:
2.2.1. Get input
2.2.2. Instantiate an object of the class
2.2.3. Use the other methods

You might also like