Syntax Flashcards

1
Q

Static variable

A

private static int n;

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

instance variable

A

private int n;

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

Static method

A

public static int calc(int a, int b) {
return a + b * 2;
}

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

Typecast

A

BankAccount myAccount = (BankAccount) anObject;

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

Instanceof

A

if (anObject instanceof BankAccount)

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

Wrapper

A

String input = “5”;
int in = Integer.parseInt(input);

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

make a child class

A

public class Child extends Parent

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

default constructor of a child class

A

super();

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

abstract class

A

public abstract class Instructions {stuff}

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

interface

A

public interface Moveable {

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

implements

A

public class Warrior implements Moveable, Drawable {

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

enum def

A

public enum FilingStatus {SINGLE,MARRIED};

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

File IO

A

open:
FileReader reader = new FileReader(filename);
read: using scanner
Scanner data = new Scanner( reader ) ;
String line = data.nextLine() ;

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

try catch

A

try {
FileReader reader = new FileReader(“input.txt”);
} catch (FileNotFoundException e) {
System.out.println(“File not found: input.txt”);
}

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

throws

A

public void loadFile3() throws FileNotFoundException {
FileReader reader = new FileReader(“input.txt”);
}

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

throw

A

if (bad stuff I detect)
throw new Exception(“blah”);

17
Q

public class Student {
protected String name;
private String address;
private int id ;
public boolean isEnrolled(int year) {
// do stuff
}
}
diagram?

A

Student
#name: String
-address: String
-id: int
—————-
+isEnrolled(year:int) : boolean

18
Q

public class GamePanel {
public static final int CELL_SIZE = 20;
private int whoseTurn;
public void drawBoard (Graphics g) { }
}

A

+CELL_SIZE: int = 20
-whoseTurn: int
—————–
+drawBoard(g:graphics)