CMSC 131 (Summer 2019) Week 06 Study Questions Flashcards

1
Q

True/False: In order to run a static method, you must run it for a particular object (the current object).

A

False

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

True/False: In order to run an instance method, you must run it for a particular object (the current object).

A

True

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

True/False: An instance variable can be declared as “static”.

A

False

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

True/False: The same class can contain some members that are static and some members that are non-static.

A

True

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

Which kinds of variables are given default values if you do not initialize them? (Local/ instance/static? Which ones?)

A

instance and static

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

What default values are used for the variables mentioned above?

A

0 for all primitive types (false for boolean, ASCII code 0 for char); “null” for reference variables

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

When writing JUnit tests, is it better to write many small tests, or a few long ones?

A

Lots of small ones

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

What is JUnit?

A

A useful feature of Java that allows us to quickly write “unit tests” for classes we are writing. The tests can be run conveniently and repeatedly so that as changes are made to the code we can quickly verify that everything still works properly!

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

Give an example of the correct syntax for “assertTrue” in a JUnit test.

A

assertTrue(x < 4); // test will pass if and only if the value of x is less than 4

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

If a JUnit test has several separate assertions in it, will the test continue after one of the assertions fails?

A

No

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

If a JUnit test suite has several different JUnit tests in it (separate methods), will the rest of the tests run after one of them fails?

A

Yes

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