what string method finds the position of '-' in "3-8"?
indexOf()
this method runs automatically when you create a new object
constructor
this operator returns true only if both conditions are true
&&
if you write int feet = 5; inside a constructor, this creates what type of variable?
local
a constructor must have the same name as this
class name
the expression !(false && true) evaluates to this
true
if a constructor parameter has the same name as an instance variable, what key word refers to the instance variable
this
what string method extracts part of a string using start and end positions?
substring()
This java keyword can be used in a constructor to enforce that a condition like b != 0 is true during development
assert
what does !(false || true) evaluate to?
which type of variable belongs to the object itself and is declared outside of the constructor?
instance variable
what method converts "8" into the integer 8?
Integer.parseInt()
if a and b are not allowed to be equal to 0, and the constructor allows a = 0 and b = 0 the object can enter this undesirable condition
invalid state
what is the difference between && and ||
&& requires both conditions to be true
|| requires at least one condition to be true
if a constructor parameter has the same name as an instance variable and you do not use this, which variable gets assigned?
the parameter (local variable)
what does this print?
String s = "2-6";
int dash = s.indexOf('-');
System.out.println(s.substring(dash));
-6
once an object is created, it should always satisfy its rules. This principle is called maintaining ____
class invariants
why does the order of conditions matter when using &&?
because the first condition may prevent the second from executing.
what will getFeet() return after this constructor runs?
private int feet = 3
public Measurement(int feet) {
feet = feet + 2;
}
3
instance variable never updated