Final Flashcards

1
Q

Where do you initialize the variable when dealing with loops?

A

Before the loop

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

How do you check if two strings are equal?

A

A.equals(b)

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

What do you do if you might not always want this.a = a; to be called?

A

You can put an if statement wether it happens or not depending on the condition you set.

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

How do you call a method?

A

Just call it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
Animal c = new Cat();
Which methods are available to c?
A

Only animal methods not cat methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
Animal c = new Cat();
How do you make cat methods available to c?
A

Cat d = (Cat) c;

Then call on d for the cat methods

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

I’m abstract classes and methods is the a big or small?

A

Small

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

How do you implement a child class?

A

Public class child extends parent{}

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

How do you implement an interface?

A

Public class myclass implements interface1{}

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

If a class has no parent, which class does it extend?

A

Object class

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

How can you simply throw an exception?

A

If () { throw new exception(“error”); }

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

How do you check if something is of object type?

A

If (x instanceof objectType){}

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

What’s the difference between checked and unchecked exceptions.

A

Checked exceptions need to be caught or thrown (file is not found), unchecked (input mismatch) are runtime errors and don’t get found until runtime. Checked won’t let the program run if problem.

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

How do enhanced for loops work?

A

They actually create new temporary items unlike just a numerical counter.
For (Passenger p : passengers){
P.setName(“sally”);
}

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

How do you find the ASCII code for an item?

A

.charAt() and put an index value in the brackets if finding for an array or list

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

Do you have to call super in order for a hold to call their parents default constructor?

A

No

17
Q

Where do super calls go?

A

Only on the first line of a method or constructor.

18
Q

How do you build an arrayList of objects?

A

ArrayList prey = new ArrayList();

19
Q

When building a child class, if the constructor uses some similar parameters how do you access them instead of repeating code?

A

Super(a ,b)

20
Q

How do you implement try catch

A

Try{block of code}

Catch(exception e){block of code}