CMSC 131 (Summer 2019) Week 06 Study Questions Flashcards
True/False: In order to run a static method, you must run it for a particular object (the current object).
False
True/False: In order to run an instance method, you must run it for a particular object (the current object).
True
True/False: An instance variable can be declared as “static”.
False
True/False: The same class can contain some members that are static and some members that are non-static.
True
Which kinds of variables are given default values if you do not initialize them? (Local/ instance/static? Which ones?)
instance and static
What default values are used for the variables mentioned above?
0 for all primitive types (false for boolean, ASCII code 0 for char); “null” for reference variables
When writing JUnit tests, is it better to write many small tests, or a few long ones?
Lots of small ones
What is JUnit?
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!
Give an example of the correct syntax for “assertTrue” in a JUnit test.
assertTrue(x < 4); // test will pass if and only if the value of x is less than 4
If a JUnit test has several separate assertions in it, will the test continue after one of the assertions fails?
No
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?
Yes