Week 3 Flashcards

1
Q

Objects are defined by

A

classes rather than a primitive type. (variables can be used to store primitive types).

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

objects are created with the…

A

new operator and a variable that can then be assigned to reference the object.

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

an object variable is a…

A

reference variable. It doesn’t hold the object but rather the memory location where the object is.

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

creating an object is called

A

instantiation

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

an object is a(an) _________ of a particular class

A

instance

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

objects unlike primitives can have what?

A

methods.

  • provide functionality – ex. The nextInt() method reads user input
  • invoked using the dot operator
  • a method may return a value int count = title.length()
  • a method may accept parameters as input myScan.userDelimiter(“, “)
  • may have both a return value and parameters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Assignment takes a …

A

copy of a value and stores it in a variable

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

two or more references are called what?

A

aliases

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

What happens when when an object no longer has any references to it?

A

it can’t be accessed and is called garbage.

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

immutable

A

String objects cannot be changed in memory once created.

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

the replace() method

A

returns a whole new String object

String title = title.replace(“s”, “S”);

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

String Indexes

A
  • Characters are indexed starting at 0.
  • you can get a particular character from a String using the charAt()
  • Ex. String my String = “Hello”;
  • Ex. Char myChar = myString.charAt(0); this would get the H
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

JCL

A

Java Class Library (JCL) is a set of classes that are part of the JDK and documented in the Java API. Classes are organized into packages (java.lang, java.applet, java.util, etc.)

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

the methods of the Math class are what?

A

static methods. They can be invoked using the class name rather than an object reference. (ex. Math.sqrt(delta))

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

DecimalFormat class

A

class can be used to format both floating point and integer values in various ways. The constructor takes a String that represents the pattern for formatting. The format method is called on the DecimalFormat object to return a String representing the value.

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

bankers rounding in java

A

rounds to the nearest even but confusing and dumb

17
Q

Wrapper class

A

is a class whose object wraps or contains primitive data types. When we create an object to a wrapper class, it contains a field and in this field, we can store primitive data types. In other words, we can wrap a primitive value into a wrapper class object.

18
Q

autoboxing

A
the automatic conversion of a primitive value to a corresponding wrapper.
    Integer obj;
    int num = 42;	
    obj = num;
-int i = Integer.partInt(“1234”);
-double x = Double.parseDouble(“12.34”);