Description: Introduction to the concepts of a class definition, fields, constructors, methods (getters/setters), and instances. This is one of the most important topics to start working with Object-Oriented Programming (OOP).
ACM CCECC
N/A
AP CS A
[Objects and Classes]
MOD-1.B.2 A class is the formal implementation, or blueprint, of the attributes and behaviors of an object.
CS1
[Objects and Classes]
130.422.c.1.a Use program design problem-solving strategies to create program solutions;
Description: Start of the robot project by using the concepts learned in the previous video. In this occasion, the student will define the fields and constructors of the robot along with its fundamental UML.
ACM CCECC
N/A
AP CS A
[Instance Fields, Methods, and Static Modifier]
MOD-2.E Define behaviors of an object through void methods with or without parameters written in a class.
MOD-2.E.1 A void method does not return a value. Its header contains the keyword void before the method name.
MOD-2.E.2 A mutator (modifier) method is often a void method that changes the values of instance variables or static variables
MOD-2.F Define behaviors of an object through non-void methods with parameters written in a class.
MOD-2.F.1 Methods can only access the private data and methods of a parameter that is a reference to an object when the parameter is the same type as the method’s enclosing class.
MOD-2.F.2 Non-void methods with parameters receive values through parameters, use those values, and return a computed value of the specified type.
MOD-2.F.3 It is good programming practice to not modify mutable objects that are passed as parameters unless required in the specification.
MOD-2.F.4 When an actual parameter is a primitive value, the formal parameter is initialized with a copy of that value. Changes to the formal parameter have no effect on the corresponding actual parameter.
MOD-2.F.5 When an actual parameter is a reference to an object, the formal parameter is initialized with a copy of that reference, not a copy of the object. If the reference is to a mutable object, the method or constructor can use this reference to alter the state of the object.
MOD-2.F.6 Passing a reference parameter results in the formal parameter and the actual parameter being aliases. They both refer to the same object.
MOD-2.G Define behaviors of a class through static methods.
MOD-2.G.1 Static methods are associated with the class, not objects of the class.
MOD-2.G.2 Static methods include the keyword static in the header before the method name.
MOD-2.G.3 Static methods cannot access or change the values of instance variables.
MOD-2.G.4 Static methods can access or change the values of static variables.
MOD-2.A.6 Access to behaviors can be internal or external to the class. Therefore, methods can be designated as either public or private.
MOD-1.F.3 Methods are said to be overloaded when there are multiple methods with the same name but a different signature.
MOD-2.D Define behaviors of an object through non-void methods without parameters written in a class.
MOD-2.D.1 An accessor method allows other objects to obtain the value of instance variables or static variables.
MOD-2.D.2 A non-void method returns a single value. Its header includes the return type in place of the keyword void.
MOD-2.D.3 In non-void methods, a return expression compatible with the return type is evaluated, and a copy of that value is returned. This is referred to as “return by value.”
MOD-2.D.4 When the return expression is a reference to an object, a copy of that reference is returned, not a copy of the object.
MOD-2.D.5 The return keyword is used to return the flow of control to the point immediately following where the method or constructor
MOD-2.D.6 The toString method is an overridden method that is included in classes to provide a description of a specific object. It generally includes what values are stored in the instance data of the object.
MOD-2.D.7 If System.out.print or System.out.println is passed an object, that object’s toString method is called, and the returned string is printed.
MOD-2.G.5 Static methods do not have a this reference and are unable to use the class’s instance
MOD-3.A.4 The provided accessor and mutator methods in a class allow client code to use and modify data.
[The this Reference Variable]
VAR-1.H Evaluate object reference expressions that use the keyword this.
VAR-1.H.1 Within a non-static method or a constructor, the keyword "this" is a reference to the current object—the object whose method or constructor is being called.
VAR-1.H.2 The keyword this can be used to pass the current object as an actual parameter in a method call.
[toString and equals Method]
CON-1.H.2 Object reference values can be compared, using == and !=, to identify aliases.
CON-1.H.3 A reference value can be compared with null, using == or !=, to determine if the reference actually references an object.
CON-1.H.4 Often classes have their own equals method, which can be used to determine whether two objects of the class are equivalent.
CS1
N/A
Description: The class that contains the main and the one that is also intended for the user of a robot to modify is the Tester class. In this session, the student will visualize the implementation of that class in order to interact with the previously created methods.
ACM CCECC
N/A
AP CS A
[Constructors]
MOD-1.B Explain the relationship between a class and an object.
MOD-1.B.1 An object is a specific instance of a class with defined attributes
MOD-1.D For creating objects - a. Create objects by calling constructors without parameters b. Create objects by calling constructors with parameters
MOD-1.D.1 Every object is created using the keyword new followed by a call to one of the class’s constructors.
MOD-1.D.3 Existing classes and class libraries can be utilized as appropriate to create objects.
[Instance Fields, Methods, and Static Modifier]
MOD-1.E Call non-static void methods without parameters.
MOD-1.E.1 An object’s behavior refers to what the object can do (or what can be done to it) and is defined by methods.
MOD-1.E.5 Non-static methods are called through objects of the class.
MOD-1.E.6 The dot operator is used along with the object name to call non-static methods.
MOD-1.E.8 Using a null reference to call a method or access an instance variable causes a NullPointerException to be thrown.
MOD-1.H Call static methods.
MOD-1.H.1 Static methods are called using the dot operator along with the class name unless they are defined in the enclosing class.
CON-1.H.1 Two object references are considered aliases when they both reference the same object.
[Defining and Calling a Method]
MOD-1.F Call non-static void methods with parameters.
CS1
N/A
Description: In this session, we discuss the principles of inheritance, which is a powerful tool to reuse methods from another class and extend the capabilities of an object.
ACM CCECC
[Inheritance]
PL-01. Design a simple class hierarchy using superclasses, subclasses, and abstract classes.
[Superclass Constructor and Methods]
PL-04. Implement in code OOP constructs, including encapsulation, abstraction, inheritance, and polymorphism.
AP CS A
[Inheritance]
MOD-3.B Create an inheritance relationship from a subclass to the superclass.
MOD-3.B.1 A class hierarchy can be developed by putting common attributes and behaviors of related classes into a single class called a superclass.
MOD-3.B.2 Classes that extend a superclass, called subclasses, can draw upon the existing attributes and behaviors of the superclass without repeating these in the code.
MOD-3.B.3 Extending a subclass from a superclass creates an “is-a” relationship from the subclass to the superclass.
MOD-3.B.4 The keyword extends is used to establish an inheritance relationship between a subclass and a superclass. A class can extend only one superclass.
MOD-3.C.3 If S is a subclass of T, then a reference of type T can be used to refer to an object of type T or S.
MOD-3.C.4 Declaring references of type T, when S is a subclass of T, is useful in the following declarations— ● Formal method parameters ● arrays — T[] var ArrayList<T> var.
MOD-3.D Call methods in an inheritance relationship.
MOD-3.D.1 Utilize the Object class through inheritance.
MOD-3.D.2 At compile time, methods in or inherited by the declared type determine the correctness of a non-static method call.
MOD-3.D.3 At run-time, the method in the actual object type is executed for a non-static method call.
MOD-3.E Call Object class methods through inheritance.
MOD-3.E.1 The Object class is the superclass of all other classes in Java.
MOD-3.E.4 Subclasses of an Object often override the equals and toString methods in class-specific implementations
MOD-3.E.2 The Object class is part of the java.lang package.
MOD-3.E.3 The following Object class methods and constructors—including what they do and when they are used—are part of the Java Quick Reference— ● boolean equals(Object other) ● boolean equals(Object other)
[Superclass Constructor and Methods]
MOD-3.B.5 Constructors are not inherited.
MOD-3.B.6 The superclass constructor can be called from the first line of a subclass constructor by using the keyword super and passing appropriate parameters.
MOD-3.B.7 The actual parameters passed in the call to the superclass constructor provide values that the constructor can use to initialize the object’s instance variables.
MOD-3.B.8 When a subclass’s constructor does not explicitly call a superclass’s constructor using super, Java inserts a call to the superclass’s no-argument constructor.
MOD-3.B.9 Regardless of whether the superclass constructor is called implicitly or explicitly, the process of calling superclass constructors continues until the Object constructor is called. At this point, all of the constructors within the hierarchy execute beginning with the Object constructor.
MOD-3.B.10 Method overriding occurs when a public method in a subclass has the same method signature as a public method in the superclass.
MOD-3.B.11 Any method that is called must be defined within its own class or its superclass.
MOD-3.B.12 A subclass is usually designed to have modified (overridden) or additional methods or instance variables.
MOD-3.B.13 A subclass will inherit all public methods from the superclass; these methods remain public in the subclass.
MOD-3.B.14 The keyword super can be used to call a superclass’s constructors and methods.
MOD-3.B.15 The superclass method can be called in a subclass by using the keyword super with the method name and passing appropriate parameters.
MOD-3.C Define reference variables of a superclass to be assigned to an object of a subclass in the same hierarchy.
MOD-3.C.1 When a class S “is-a” class T, T is referred to as a superclass, and S is referred to as a subclass.
MOD-3.C.2 If S is a subclass of T, then assigning an object of type S to a reference of type T facilitates polymorphism.
CS1
N/A