CMPS 161/280 Flashcards

1
Q

What is an Object?

A

a self-contained component that contains properties and methods needed to make a certain type of data useful. An object’s properties are what it know and its methods are what it can do.

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

What is a Class?

A

a blueprint or template or set of instructions to build a specific type of object. Every object is built from a class.

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

What is instantiation?

Give an example.

A
The process of a class being used to create an object.
SimpsonsCharacter bart = new SimpsonsCharacter();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the Public access modifier mean?

A

Any class can refer to the field or call the method.

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

What does the Private access modifier mean?

A

Only the current class will have access to the field or method.

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

What does the Protected access modifier mean?

A

Only the current class and subclasses of this class will have access to the field or method.

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

What is a Method?

What is the syntax for a Method?

A

Syntax: {access} {use} {return type} methodName({parameters})

Behavior of objects are represented as methods.
 methodName(parameters)
{
     method body;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the return types for a method?

A

Int, String, Boolean, Object, void?

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

What is a static method?

A

Static methods are meant to be relevant to all instances of a class rather than to any specific instance. They are called “static” because they are resolved at compile time based on the class they are called on. They can’t be overriden.

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

Considering Arguments, what is Pass by Value?

A

Making a copy in memory of the actual parameter’s value that is passed in, a copy of the contents of the actual parameter.

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

Considering arguments, what is Pass by Reference?

A

A copy of the address of the actual parameter is stored. Use pass by reference when you are changing the parameter passed in by the client program.

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

What are the 8 basic data types in Java?

A

byte, short, int, long, float, double, boolean, char

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

What is the Byte data type?

A

Byte data type is an 8-bit signed two’s complement integer.

Minimum value is -128 (-2^7)
Maximum value is 127 (inclusive)(2^7 -1)

Example: byte a = 100 , byte b = -50

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

What is the Short data type?

A

Short data type is a 16-bit signed two’s complement integer.

Minimum value is -32,768 (-2^15)

Maximum value is 32,767 (inclusive) (2^15 -1)

Example: short s = 10000, short r = -20000

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

What is the int data type?

A

Int data type is a 32-bit signed two’s complement integer.

Minimum value is - 2,147,483,648.(-2^31)
Maximum value is 2,147,483,647(inclusive).(2^31 -1)

Example: int a = 100000, int b = -200000

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

What is the long data type?

A

Long data type is a 64-bit signed two’s complement integer.

Minimum value is -9,223,372,036,854,775,808.(-2^63)
Maximum value is 9,223,372,036,854,775,807 (inclusive). (2^63 -1)

Example: long a = 100000L, long b = -200000L

17
Q

What is the float data type?

A

Float data type is a single-precision 32-bit IEEE 754 floating point.

Float is mainly used to save memory in large arrays of floating point numbers.

Example: float f1 = 234.5f

18
Q

What is the double data type?

A

double data type is a double-precision 64-bit IEEE 754 floating point.

This data type is generally used as the default data type for decimal values, generally the default choice.

Example: double d1 = 123.4

19
Q

What is the boolean data type?

A

boolean data type represents one bit of information.

There are only two possible values: true and false.

This data type is used for simple flags that track true/false conditions.

Example: boolean one = true

20
Q

What is the char data type?

A

char data type is a single 16-bit Unicode character.

Minimum value is ‘\u0000’ (or 0).

Maximum value is ‘\uffff’ (or 65,535 inclusive).

Char data type is used to store any character.

Example: char letterA =’A’