AP Flashcards
WHEN GIVEN A METHOD USE THE METHOD MAKE UR CODE EFFICIENT PLEASE GOOD GOLLY GOD GOSH JEEZ LoUIS
can you use == for doubles?
NAHHHH, only for ints and booleans (because giant doubles are approximations of real numbers)
point of wrappers
such as arrraylists, to put ints and doubles into an object-only area
if you fail to initalize a local variable in a method, this is the only case where…
the variable does NOT get initalized to null/default automatically
4/23/24 camera roll
“removed.add(memberList.get(i))
memberList.remove(i)
“
can be simplified down to:
remove.add(memberList.remove(i));
super.method or method.super?
super.method(PARAMETER(s))
can you overload an inherited method?
yes!
you can declare variables in a loop and have it just keep getting redeclared and adjust for every object buster
what do you use for a boolean, .equals or ==?
==
why cant you edit a for each loop?
because such as in for ( int num : nums), num is a variable declared in the header, or a COPY of nums. editing num edits the instance variable
modifier methods are what make an object…
mutable (integer class is immutable)
lists can be mutable if youre in a class and you have a _____ via a for each loop
modifer method
true/false: subclasses inherit the constructors of superclasses
false, they need to specify their own constructors (unless the subclass has no constructors, in which java creates an automatic no args)
12-2-10: When will the method stringRecursion produce a run time error?
public void stringRecursion(String s)
{
if (s.length() < 16)
{
System.out.println(s);
}
stringRecursion(s + “*”);
}
A. It will never produce a run time error.
B. It will always produce a run time error.
C. Only when the length of the input string is greater than or equal to 16.
D. Only when an empty string is input.
E. Whenever the input string length is less than 16.
B, the length conditional is within the if but the increases in length via extra *’s are outside the if