3.Java fundamental theory
private mutator reference overridden Final
"An object is considered immutable if its state cannot change after it is constructed" For a class to be immutable.... • All data fields must be _ • There can't be any _ (set) methods for data fields • No accessor methods can return a _ to a data field that is mutable • Ensure the class cannot be _ - make the class _
getter setter
A _ is used to access private instance variables. A _ is used to set private instance variables.
is-a
A subclass and its superclass must have the _ relationship.
data fields methods
A subclass inherits accessible _ and _ from its superclass and may also add new data fields and methods
restrict methods instance
Access modifiers can be used to _ access to _ and _ variables.
accessible private
An instance method (new) can be overridden only if it is _. Thus a _ method cannot be overridden, because it is not accessible outside its own class. If a method defined in a subclass is private in its superclass, the two methods are completely unrelated.
aggregating
An object can be owned by several other _ objects. If an object is exclusively owned by an aggregating object, the relationship between the object and its aggregating object is referred to as a composition
variable
Both getters and setters should follow the JavaBeans naming convention. They should start with get, set, or is, followed by the _ name (starting with a capital letter).
No. (This is a syntax error)
Can a subclass of Circle access the toString method defined in the GeometricObject class using syntax such as super.super.toString()?
reused static method
Code cannot be _ in other programs if is in the main. method. To make it reusable, define a _
restrictive bugs
Every method and instance variable should use the most _ access modifier possible. The promotes good encapsulated design by protecting data and helps reduce the areas in which _ can be inadvertently introduced.
customization constructors properties methods
From a class developer's perspective, a class is designed for use by many different customers. In order to be useful in a wide range of applications, a class should provide a variety of ways for _ through _, _, and _
instance
In most classes, all the _ variables will use the private access modifier. The public methods should be the only methods that other classes need to use this class. Any method used internally and not required by external classes should not be public.
data operations
In procedural programming, _ and _ on the data are separate, and this methodology requires passing data to methods. Object-oriented programming places data and the operations that pertain to them in an object. This approach solves many of the problems inherent in procedural programming. The object-oriented programming approach organizes programs in a way that mirrors the real world, in which all objects are associated with both attributes and activities.
inherited overridden hidden SuperClassName.staticMethodName
Like an instance method, a static method can be _. However, a static method cannot be _. If a static method defined in the superclass is redefined in a subclass, the method defined in the superclass is _. The hidden static methods can be invoked using the syntax _
Inheritance
Object-oriented programming allows you to define new classes from existing classes. This is called _.
multiple methods signatures
Overloading means to define _ with the same name but different _. This occurs at compile time.
parameters types
The conditions for method overloading: • The number of _ is different for the methods • (and/or) The Parameter _ are different
encapsulated
The details of implementation are _ and hidden from the user.
specialization
The inheritance relationship enables a subclass to inherit features from its superclass with additional new features. A subclass is a _ of its superclass; every instance of a subclass is also an instance of its superclass, but not vice versa
data methods objects
The object-oriented paradigm couples _ and _ together into _. The object-oriented approach combines the power of the procedural paradigm with an added dimension that integrates data with operations into objects
data methods objects
The object-oriented paradigm couples _ and _ together into _. Software design using the object-oriented paradigm focuses on objects and operations as objects
any package subclass package class
The public access modifier allows _ class to access the public method or instance variable. The protected access modifier allows classes that are in the same _ or are in a _ to have access to the method or instance variable. The default or package-private access modifier allows classes that are in the same _ to access the methods or instance variable. The private access modifier allows only methods in the same _ to access the private method or instance variable.
class data fields
The scope of (instance and static) variables is the entire _, regardless of where the variable is declared For consistency, declare _ _ at the beginning of your classes
local method
To avoid confusion and mistakes, do not use the names of instance or static variables as _ variable names, except for _ parameters.
same signature return
To override a method, the method must be defined in the subclass using the _ and the same _ type as in its superclass. Overriding occurs at runtime.
reusability developmaintain
Using objects improves software _ and makes programs easier to _ and easier to _. Programming in Java involves thinking in terms of objects; a Java program can be viewed as a collection of cooperating objects.
1234
What is the order the results will be printed? public class Faculty extends Employee { public static void main(String[] args) { new Faculty(); } public Faculty() { System.out.println("(4) Performs Faculty's tasks"); } } class Employee extends Person { public Employee() { this("(2) Invoke Employee's overloaded constructor"); System.out.println("(3) Performs Employee's tasks "); } public Employee(String s) { System.out.println(s); } } class Person {public Person() { System.out.println("(1) Performs Person's tasks"); } }
class encapsulation
What is this an example of? Creating a Circle object and finding the area of the circle without knowing how the area is computed.
restrictive
When creating methods or instance variables, the most _ access modifier possible should be used.
super
You must use the keyword _ to call the superclass constructor, and the call must be the first statement in the constructor. Invoking a superclass constructor's name in a subclass causes a syntax error.
no-arg constructor
You should provide a _ for every class to make the class easy to extend and to avoid errors.
Private accessors
_ data fields in a superclass are not accessible outside the class. Therefore, they cannot be used directly in a subclass. They can, however, be accessed/mutated through public _ if defined in the superclass.
Local Hidden local
_ variable - variable declared inside a method _ variables: "If a local variable has the same name as a class's variable, the _ variable takes precedence and the class's variable with the same name is hidden"
more
a subclass is not a subset of its superclass. In fact, a subclass usually contains _ information and methods than its superclass.
Aggregation
association that represents an ownership relationship between two objects. Aggregation models has-a relationships.
Overriding
provide a new implementation for a method in the subclass.
super
public void printCircle() { System.out.println("The circle is created " + _.getDateCreated() + " and the radius is " + radius); }
Class abstraction
separation of class implementation from the use of a class.
Encapsulation
the concept of storing related data and code together
Information hiding
the concept of using restrictive access modifiers to hide the implementation details of a class.
variable subtype
• Polymorphism = "many forms/shapes" Polymorphism means that a _ of a supertype can refer to a _ object
super
• The keyword _ refers to the superclass and can be used to invoke the superclass's method and constructors
Super() method
• To call a superclass constructor _, or super(parameters); • To call a superclass method - Super._(parameters);