OOP - Week 3 Flashcards

1
Q

What is a Class

A

A class is a set of instructions that describe how an object can behave and what information it contains

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

What are some pre-defined classes

A

System, Integer, String, Arrays, Math

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

What is a class made of

A

Fields - variables
Methods - functions
Constructors - to initialise objects

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

Class syntax

A
public class name {
//code
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Access Modifiers

A

public - accessed everywhere
protected - same package and subclasses
no modifier - same package
private - its own class

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

What is a constructor

A

A special method used to initialise objects and fill out the class template

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

Constructor syntax

A

public (classname) (variables)

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

Escape sequence character

A

Backslash

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

What must be different to make several constructors in one object

A

Number of parameters or datatype

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

Key string methods

A
String concat(String str)
char charAt(int index)
int length()
String trim()
booleanStartsWithStr(String str)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does it mean if printing a line outputs I@…

A

The object can be passed as a reference

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

How to compare the actual value of a string

A

str1.equals(str2)

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

How to compare alphabetic order between strings

A

str1.compareTo(str2)

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

What is the scanner class

A

Enables a program to read data for use in a program

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

How to use the scanner class

A

import java.util.Scanner;

Add a public scanner class

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

How to get input

A

new Scanner(System.in)

17
Q

How to wait for an integer input

A

scannerName.nextInt()