mode 3 Flashcards
What is an access level?
They’re levels of control that determine who/what has access to a specific object/class/method/variable
Are Access Levels and Scopes the same things?
NO!
- -Scopes define where a member exists (Lifespan)
- -Access Levels define who has access to a member when it already happens to exist (permission)
What are the Access Levels in Java?
- > 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
Encapsulation: How do we properly encapsulate?
By making the fields private
And make getters & setters that have greater visibility than private
What is a POJO?
Plain Old Java Object
Basically, any object you ever create will be a POJO.
What is a Java Bean?
A Java Bean is a POJO that passes 3 criteria
- It has a no arg constructor
- Its fields are properly encapsulated
- It implements Serializable
Are all POJOs java beans?
All JavaBeans are POJOS…..BUT….not all POJOs are JavaBeans
What is a wrapper class?
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.
What are the wrapper classes
- Each primitive datatype has a wrapper class counterpart:
- int Integer
- double Double
- float Float
- char Character
- boolean Boolean
- byte Byte
- short Short
- long Long
What is “autoboxing”?
Autoboxing is when a wrapper class is given the primitive counterpart it will AUTOMATICALLY convert the primitive to the respective wrapper class
What is “unboxing”?
Unboxing is the opposite of autoboxing
The “final” modifier.
What is the “final” keyword in java?
A keyword that will make the variable immutable (cannot be changed) after it has been assigned.
What does the “final” keyword do in java?
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
Can we have final on constructor, initializer block, final abstract class, final interface?
- 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