What does UML stand for?
Unified Modelling Language
Basic UML Class Diagram components
its a box
with a section for the name
one for the attributes (with heading ‘attributes’)
one for the methods (with heading ‘methods’)
how to specify public and private in UML diagram
+, - and # are used to indicate the visibility of a member in uml
+ is public
- is private
# is protected
Basic UML Abstract class Diagram component
method name should be in italic
if one method is abstract , the class is abstract
name {abstract} alternative annotation
Uml inheritance ( is - a ) relationship
What is OOP?
Object-oriented programming (OOP) models real-world elements using objects that interact by exchanging messages (calling methods).
What is a class?
A blueprint for creating objects. It defines the behavior (methods) and properties (attributes) of the objects.
What are attributes/instance variables?
Variables within a class that store the properties of an object.
What does the private keyword do?
private
Restricts access to instance variables from outside the class, encapsulating the object's data.
What is a constructor?
A special method that creates objects, allocates memory, and initializes the object's variables.
What is the syntax of a constructor?
Same name as the class and no return type.
What is a default constructor?
Java provides a default constructor if none is defined, which initializes instance variables with default values.
What are parameterized constructors?
Constructors that accept arguments to initialize instance variables with specific values when the object is created.
What does the this keyword refer to?
this
Inside a constructor, this refers to the current object and is used to access or modify its attributes.
What is inheritance?
Creating new classes (derived/subclasses) from existing ones (base/superclasses). This establishes an "is-a" relationship.
What are the benefits of inheritance?
Code reuse: Subclasses inherit attributes and methods from superclasses, avoiding code duplication.
Maintainability: Changes to shared code only need to be made in the superclass.
Extensibility: New functionality can be added by creating new subclasses.
What is specialization in inheritance?
Subclasses are more specific versions of their superclass.
What is generalization in inheritance?
The process of extracting common features from multiple classes into a superclass to reduce redundancy.
What does the extends keyword do?
extends
Used to establish an inheritance relationship between a subclass and a superclass.
What does the super keyword do?
super
A reference to the superclass, used to call superclass constructors or access superclass members.
What does the protected access modifier do?
protected
Allows subclasses to directly access attributes of the superclass, while still restricting access from other external classes.
What is an abstract class?
Abstract classes cannot be instantiated. They serve as templates for subclasses, defining common behavior and attributes that subclasses must implement.
What is an abstract method?
Declared in abstract classes without implementation. Subclasses are required to provide the implementation.
What keyword is used to define abstract classes and methods?
abstract
What is an association?
An association represents a "has-a" relationship between objects of different classes.
What is cardinality in associations?
Defines the number of objects involved in the relationship (e.g., one-to-one, one-to-many).
What is directionality in associations?
Indicates which class(es) "know" about the other class.
How are associations implemented?
Associations are implemented using instance variables that hold references to other objects.
What is composition?
A strong form of association, a "whole-part" relationship where the part is dependent on the whole.
What are class variables (static variables)?
Attributes that belong to the class itself, not to specific instances.
There is only one copy of a static variable, shared by all objects of the class.
Used to store values that are common to all instances of a class.
Declared using the static keyword.
static
What are class methods (static methods)?
Methods that belong to the class and can be called without creating an instance of the class.
They can only access static variables.
Why encapsulate game logic?
Encapsulating game logic in a separate class improves modularity, maintainability, and flexibility.
What do instance variables represent in a game?
The state of a game object.
Last changeda month ago