Level 13 Level 15
Level 14

[Quiz] Basics III


58 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
An array is a variable that
can hold a bunch of values
index 0
Arrays index starts at ?
of the same type
An Array can only contain values
dataType[] arrayName = new dataType[sizeOfArray];
give the guide to declare an array
int[] numberArray = new int[10];
declare an array of integers with 10 objects
randomArray[1] = 2;
you can add values to an array individually by calling the index. example
give example of a string Array
String[] stringArray = {"Just", "Random", "Words"};
add values with a for loop
for(int i = 0; i < numberArray.length; i++){
Two [ ] [ ] boxes for multiple values.
A multiDimensional array is declared just like an array, but with
Arrays.fill(moreNumbers, 2);
what command fills an Array with a default value
it automatically resizes
ArrayList differs from an array because
yes
Are variable names case-sensitive?
.add()
what keyword adds elements to an ARrayList?
.add(index, "Stuff")
how do you add elements to a specific index
.set();
How do you replace a value
.remove():
how do you remove a value?
.removeRange(x,y);
How do you remove a range of elements?
hasNext() determines if
There is another value left in the array
variablebeCopiedTo.addAll(CopiedFrom)
what keyword adds all the elements in one array to another?
.clear()
how do you delets a arrayList
.isEmpty();
Check if an arrayList is empty
toArray does what?
converts the ArrayList into an array of objects
toString does what?
converts items in the array into a String
bytecodes
.class files do not contain code native to a person's processor; what does it contain instead?
What are bytecodes?
The machine language of the Java Virtual Machine (Java VM)
The Java Virtual Machine (Java VM) is functional on multiple operating systems
What allows the same .class file to be able to run on different operating systems?
What is a platform?
The hardware or software environment in which a program runs
It's a software-only platform that runs on top of other hardware-based platforms.
How does the java platform differe from Microsoft Windows, Linux, or Mac OS?
What is an API?
A large collection of ready-made software components that provide many useful capabilities
How are APIs grouped?
Into libraries called packages
Windows cannot find the compiler. In this case, the compiler is javac
~~'javac' is not recognized as an internal or external command, operable program or batch file~~
You forgot to include the .java suffix when compiling the program.
~~Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested~~
fields, constructor(s), methods
Simple class contains these three things
a method's signature
name and parameter types
why are method signatures important
because no method can create(ie overload) a method with the same signature
why overloading is good
creates distinct methods with same name (different parameter types, so different method signature)...that way we can "draw" an int, String, or Goat...however it "should be used sparingly since it makes code less readable"
instantiate constructor in Java
Type name = new ConstructorNameWhichWe'veAlsoNamedType(inputparam1, inputparam2);
What happens if don't provide constructor for your class
The compiler automatically provides a no-argument, default constructor for any class without constructors. This default constructor will call the no-argument constructor of the superclass. In this situation, the compiler will complain if the superclass doesn't have a no-argument constructor
within Class
make (define) a constructor in java
things we generally capitalize in Java
class names and constructor methods...we like to name the constructor the same thing as the class for convenience
how do parameters work in Java
parameters are references, whose values are not changed. the field referenced changes.
arguments can be either
primitive or reference data type (like one that you made)
how to access parameter within method, and how to access field within method
accessing parameter is easy, just write the parameter name...accessing field requires qualified name, which will be discussed in the "using this keyword" section
declaring a primitive vs reference variable
when say int x; compiler creates OBJECT.
any requirements for new's postfix argument?
well, the declaration and the constructor type must match. This can be done like so:
within it's declared class
when is it ok to use a simple field (without type in front)
how to access an object field outside it's class
objectReference.fieldName, where objectReference is reference to an object -- either a variable name or an expression such as Rectangle(origin2, 25, 30).getArea();
object fields vs _______
class fields (like static)
objectReference.methodName();
how to access a class' method outside it's class
string literal
\'
== vs equals
compares obj refs vs compares objs in RAM...... if ( name1.equals(name2) )
interface @interface ClassPreamble {
annotation types a form of
@Override @Deprecated @SupressWarnings
the three predefined annotation types
Javadoc comments
Annotations not the same as
what is this process called: Spaceship firstShip = new Spaceship();
declaring object reference, where the "new" object will exist in the heap
default value for primitives and reference
0/0.0/false for primitives and null for reference
fields
And object stores it states in _______.
Local
was defined has _______ scope