Terminology Flashcards

1
Q

What is a class in java

A

A class describes a particular kind of object. It can contain related methods and data members (variables).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is special about classes in java

A

must have the same name as the file it is contained in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give an example of a class

A

public class myClass(){

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a constructor in java

A

A special type of instance method that creates a new object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is special about a constructor in java

A

In Java, constructors have the same name as their class and have no return value in their declaration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an example of a constructor

A
public class myClass{
          // a constructor that takes no parameters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a declaration in java

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is special about declaration in java

A

Classes are always defined when they are declared, i.e., a class cannot be declared and then have its body defined elsewhere.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Give an example of declaration in java

A

the variable var is declared

int var;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is definition in java

A

Similar to a declaration except that it also reserves storage (for variables) or provides implementations (for methods).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give an example of definition in java

A
public void myMethod(){
/* A method is defined if it has brackets, a space where code goes that says what the method does. */
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is initializing in java

A

an assignment that sets the starting value of a variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an example of initializing in java

A

Example 1: an integer var is declared, defined, and initialized to the value 2.
int var = 2;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is instantiating in java

A

To allocate storage for an object in memory (involves the keyword new).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is an instantiation always followed by

A

a constructor call that initializes the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

give an example of instantiation in java

A
the keyword new instantiates the object below. An instantiation is always followed by a constructor call that initializes the object.
      MyClass myObject = new MyClass(/*parameters*/);
17
Q

What is a method in java

A

a collection of code found within a class. If the data members of a class are nouns, the methods are the verbs (the action).

18
Q

Give an example of a method

A
public class myClass{
public void myMethod(){
19
Q

What is an object in java

A

The principal code building block of Java programs.

20
Q

What does an object in a program consist of

A

Each object in a program consists of both variables (data) and methods (functionality).

21
Q

What is a parameter in java

A

a variable or object passed into a method.

22
Q

What is an example of a parameter

A

public void myMethod(int var1, double var2){

23
Q

what is a primitive in java

A

A variable defined with a primitive data type: byte, short, int, long, float, double, char, or boolean.

24
Q

What is a typecast in java

A

(1) to demote a variable from a larger capacity data type to a smaller one. (2) to re-establish the class of an object. The cast associates itself with the expression to its immediate right.

25
Q

Give an example of typecasting in java

A

Example 1: A double var is created and then typecast via “(int)” to a variable of integer type ans.
double var = 3;
int ans = (int) var;

26
Q

What is use/read in java

A

the use of a variable in the right hand side of an assignment statement.

27
Q

Give an example of use/read in java

A

Example: an integer var is declared and used in the initialization of integer ans.
int var = 2;
int ans = Math.pow(var,2);