mode 3 Flashcards

1
Q

What is an access level?

A

They’re levels of control that determine who/what has access to a specific object/class/method/variable

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

Are Access Levels and Scopes the same things?

A

NO!

  • -Scopes define where a member exists (Lifespan)
  • -Access Levels define who has access to a member when it already happens to exist (permission)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the Access Levels in Java?

A
  • > public In the class, package, children classes, and anywhere else
  • > protected In the class, package, children classes
  • > (default) In the class, package
  • > private In the class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Encapsulation: How do we properly encapsulate?

A

By making the fields private

And make getters & setters that have greater visibility than private

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

What is a POJO?

A

Plain Old Java Object

Basically, any object you ever create will be a POJO.

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

What is a Java Bean?

A

A Java Bean is a POJO that passes 3 criteria

    1. It has a no arg constructor
    1. Its fields are properly encapsulated
    1. It implements Serializable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Are all POJOs java beans?

A

All JavaBeans are POJOS…..BUT….not all POJOs are JavaBeans

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

What is a wrapper class?

A

Wrapper classes are reference type counterparts to the primitive datatypes.

  • In other words, It’s a class that “wraps” itself around a primitive datatype to
  • give the primitive functionality.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the wrapper classes

A
  • Each primitive datatype has a wrapper class counterpart:
  • int Integer
  • double Double
  • float Float
  • char Character
  • boolean Boolean
  • byte Byte
  • short Short
  • long Long
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is “autoboxing”?

A

Autoboxing is when a wrapper class is given the primitive counterpart it will AUTOMATICALLY convert the primitive to the respective wrapper class

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

What is “unboxing”?

A

Unboxing is the opposite of autoboxing

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

The “final” modifier.

What is the “final” keyword in java?

A

A keyword that will make the variable immutable (cannot be changed) after it has been assigned.

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

What does the “final” keyword do in java?

A

Final keyword on:

  • -Final on a variable means that the variable is immutable
  • -Final on a method means the method cannot be overridden
  • -Final on a static method means the static method cannot be shadowed
  • -Final on a class means the class cannot be extended
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Can we have final on constructor, initializer block, final abstract class, final interface?

A
  • NO we may not have a final constructor
  • NO we may not have a final initializer block
  • NO we may not have a final abstract class
  • NO we may not have a final interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly