Terminology Flashcards
What is a class in java
A class describes a particular kind of object. It can contain related methods and data members (variables).
What is special about classes in java
must have the same name as the file it is contained in
Give an example of a class
public class myClass(){
What is a constructor in java
A special type of instance method that creates a new object.
What is special about a constructor in java
In Java, constructors have the same name as their class and have no return value in their declaration.
What is an example of a constructor
public class myClass{ // a constructor that takes no parameters
What is a declaration in java
A statement that creates a variable, method, or class identifier and its associated attributes but doesn’t necessarily allocate storage for variables or define an implementation for methods.
What is special about declaration in java
Classes are always defined when they are declared, i.e., a class cannot be declared and then have its body defined elsewhere.
Give an example of declaration in java
the variable var is declared
int var;
What is definition in java
Similar to a declaration except that it also reserves storage (for variables) or provides implementations (for methods).
Give an example of definition in java
public void myMethod(){ /* A method is defined if it has brackets, a space where code goes that says what the method does. */
What is initializing in java
an assignment that sets the starting value of a variable.
What is an example of initializing in java
Example 1: an integer var is declared, defined, and initialized to the value 2.
int var = 2;
What is instantiating in java
To allocate storage for an object in memory (involves the keyword new).
what is an instantiation always followed by
a constructor call that initializes the object