this feature was introduced in Java SE 5.0 and are used to import static members (attributes and methods) individually or collectively
2
New cards
static imports
name the syntax:
import static ..;
import static ..\*;
3
New cards
import static java.lang.Math.\*;
type the syntax of math static import
4
New cards
wrapper classes
the class equivalent of all Java Primitive Data Types
5
New cards
java.lang
wrapper classes can be found inside the ? package and are used to create object representation of a primitive value
6
New cards
uppercase
wrapper classes can be easily memorized, they are all spelled out and all first characters are in ?
7
New cards
Boolean
wrapper class of boolean
8
New cards
Byte
wrapper class of byte
9
New cards
Character
wrapper class of char
10
New cards
Double
wrapper class of double
11
New cards
Float
wrapper class of float
12
New cards
Integer
wrapper class of int
13
New cards
Long
wrapper class of long
14
New cards
Short
wrapper class of short
15
New cards
unboxing
extracting **primitive values** from a **wrapper object** is called ?
16
New cards
boxing
converting primitive datatype to object is called ?
17
New cards
unboxing
int num2 = j.intValue();
18
New cards
boxing
Integer i = new Integer(num);
19
New cards
boxing
Integer j = new Integer(200);
20
New cards
Java SE 5
what version did a feature called Autoboxing and Autounboxing was introduced?
21
New cards
autoboxing and autounboxing
features introduced which allows us to extract primitive values from Wrapper class reference variables
22
New cards
autoboxing
name the syntax:
int num = 100;
Integer i = num;
Integer j = 200;
int num2 = j;
23
New cards
autounboxing
name the syntax:
int num = 100;
Integer i = num;
Integer j = 200;
int num2 = j;
==**int sum = i + j:**==
24
New cards
final
this keyword can be used for attributes, methods and classes
25
New cards
false
(T OF F) methods that are declared final can be overriden
26
New cards
reused and inherited
final methods can still be ? and ? it is just their implementation that you cannot change or override
27
New cards
**constants**
(final keyword) as for attributes, once declared as final you cannot change their values. they are considered as **?**
28
New cards
subclassed
classes once declared final cannot be ?
29
New cards
true
(T OR F) extending final classes will cause a compilation error
30
New cards
error
Will this produce a compilation error? (error or no error)
public class MyString extends String {}
\ (String class is a FINAL CLASS)
31
New cards
once
values for blank final variables can be assigned only ?
32
New cards
false
(T OR F)
\ (values for blank final variables can be assigned only ?). Once assigned, you __**can change its value**__
33
New cards
body
a value must be assigned to a blank final variable within the ? of the constructor.
34
New cards
cannot
(a value must be assigned to a blank final variable within the ? of the constructor). Otherwise, you ? create an object __**if you have not assigned a value to a blank variable**__
35
New cards
enum
starting Java 5, ? was added as a new language feature that allows the declaration of a fix set of constants
36
New cards
constants
all the values declared inside an enum are ? and therefore usually written in all **uppercase values**
37
New cards
enum
allows a set of values declared in a descriptive manner
38
New cards
abstract
this keyword can only be used for **classes and for methods only**
39
New cards
abstract
means that “there are no concrete implementation”
40
New cards
implementation
abstract methods do not have any ? in its method body, just the method signature
41
New cards
true
(T OR F)
as a rule, if a **class** contains an **abstract method**, the __**class**__ must also ==**be declared as abstract themselves**==
42
New cards
instantiate
if a class is declared as abstract, you __**cannot**__ ? objects from an abstract class
43
New cards
abstract classes
serves as a template that forces it subclasses to override methods that should be present in all sub-classes
44
New cards
java interface
contract between the client and the class that implements that interface
45
New cards
interface
in java, ? is used to declare a contract that should be implemented by the client code
46
New cards
abstract, instantiate
all methods in the interface are all ? and should be overriden by the implementing class, and like an abstract class, we cannot ? an object using the keyword __**new**__ because an __**interface is not a “concrete” class**__
47
New cards
inheritance
implementing multiple interfaces is java’s way to implement multiple ?
48
New cards
**public static final**
an interface can also have variables inside them but once a variable is declared it is automatically converted into a ? variable
49
New cards
constants
(**public static final**) these variables are now treated as ? which means we cannot change the values of the variables in an interface
50
New cards
public static final double pi = 3.14;
all classes that implements the interface will inherit these constant values
\ example:
\ \ what is it equivalent to:
51
New cards
**default**
in java 8, the ? method can now be included in an interface
52
New cards
default
this feature will allow the developers to create a scalable interface, an interface that can be updated without causing an error to the implementing classes
53
New cards
methods
in __**pre java 8**__, once an interface has been set and implemented by the classes you cannot add any ? in the interface, because if you do, you will __**break the chain of the interface and class implementation**__
54
New cards
default
? method is only allowed to either be public or have a default access modifier
55
New cards
protected, private
(default interface methods) the ? and ? access modifiers are not allowed to be used
56
New cards
java 8
what version was the interface static methods introduced?
57
New cards
interface static methods
these are methods declared inside an interface that has an actual method body and are declared static
58
New cards
interface static methods
since they are static they can be called thru the name of the interface
59
New cards
functional interface
essentially an interface that has only one abstract method declared
60
New cards
functional interface
on top of an interface declaration a @FunctionalInterface annotation is placed to declare an interface a ?
61
New cards
one abstract method
what is important is that the functional interface should only have ? and it can also have __**any number of default methods**__
62
New cards
Runnable, Comparable, ItemListener
functional interfaces can also be found in standard API like the ?, ? , and ?
63
New cards
Runnable, Comparable, ItemListener
these interfaces only have one abstract method in them and therefore they are considered as functional interfaces
64
New cards
lambda expressions
was introduced in java 8 to simplify calling of methods
65
New cards
\->
lambda operator
66
New cards
additional class
using the lambda operator, we can easily provide an implementation of the methods without creating any ?
67
New cards
exception
is an object representation of an abnormal condition that arises in a **code sequence either at compile time or at runtime**
68
New cards
exception object
? handles unexpected situations like network failure, misspelled or missing filename, printers that suddenly goes offline and the likes
69
New cards
exception class
is a subclass of the **Throwable** class that represents mild errors that can be caught and handled
70
New cards
error
a subclass of the **Throwable** class that represents severe problems that an application should not try to catch
71
New cards
checked, compile
exceptions can be classified either as a ? exception that can be encountered at ? time or as an unchecked exception that can be seen at runtime
72
New cards
unchecked, runtime
(exceptions can be classified either as a ? exception that can be encountered at ? time ) or as an ? exception that can be seen at ?
73
New cards
RuntimeException
unchecked exceptions are commonly known as ?
74
New cards
notify, layman
\#1 reason why we need exception handling
\ To ? the users in ? term what happened during system crash
75
New cards
save
\#2 reason why we need exception handling
\ To enable the users to ? all, if not most, unsaved data during system crash
76
New cards
exit
\#3 reason why we need exception handling
\ To enable users to ? program gracefully
77
New cards
throws
if a method is unable to complete the task in the usual way, Java allows it an **alternative exit route**: it does not seek to return a value from the method where the exception object occurred, instead it ? an object encapsulating the error information, Java then begins a search for a handler that can deal with that error
78
New cards
finally
an optional code block that is usually placed after the last catch block
79
New cards
finally block
contains codes that needs to execute regardless if there is an exception object or not
80
New cards
exception
in java, ? object is an instance of the class Exception which is a subclass of the Throwable class
81
New cards
|
in java se 7, multiple Exception objects can be caught inside the single catch block using what operator
\ catch(IOException ? SQLException ex)
82
New cards
true
(T OR F) starting java se 7, a try block can now have resource parameters
83
New cards
parameterized try block
these resources are objects that need to be closed after execution
84
New cards
false
(T OR F) any object that implements the interface java.lang.AutoCloseable which includes all types of objects that implements the interface java.io.Closeable, __**cannot**__ be used as a resource that can be passed as a parameter to a try block
85
New cards
Exception
to create your own Exception object, you simple create a class that extends the class ?
86
New cards
creating your own exception
what is being done below:
\ class **BadTastingFoodException** extends **Exception**
87
New cards
checked
extending the class **Exception** will automatically make your user defined exception a ? exception
88
New cards
unchecked
extending the class **RuntimeException** will automatically make your user-defined exception an ? exception
89
New cards
assertion
a statement in java which ensures the correctness of any assumptions which have been done in the program
90
New cards
true
when an assertion is executed it is assumed to be **?**
91
New cards
AssertionError
if the assertion is __**false**__ the JVM will throw an ?
92
New cards
runtime
assertion checks can be programmatically placed in codes and can be **enabled** or **disabled** during ?
93
New cards
assertion checking
what is happening below:
assert
94
New cards
assertion checking
what is happening below:
assert : ;
95
New cards
\-ea
if you want to enable the assertion check you may want to rerun your application by adding the ? after the java keyword
\ java ? TestAssert 15 300
96
New cards
detail_expression
if you want to customize the displayed message, you can customize the part
97
New cards
AssertionError
if the returns a false value it will throw an ?
98
New cards
true
(T OR F) only an interface can extend to multiple interfaces