OOP terms Flashcards
what are the attributes of the object
its state eg colour, age,, size
what is the behaviour of the object
its functionality eg walk, sing
what is a class
a blueprint for a custom type
what does UML stand for
unified modeling language
what does + mean inUML
Public
what does - mean in UML
Private
create an object of class student
Student studentName = new Student();
what does encapsulate mean
not allow it to be exposed to the world
when are getters and setters used
when variables are private
why do we use getters and setters rather than leaving variables public
so that they cant be changed to crap eg length being a minus number
what is stack memory used for
variables and function calls
what is heap memory used for
to store objects
formal name for getters and setters
instance methods
accessors and mutators
creating an array of objects
type(class name) arrayName = new type[x]
what is method overloading
when there are more than one method with the same name but the compiler can tell them apart by their parameters/ list of parameters
why might static variables be used
universal to everyone
how are static variables accessed
ClassName.VariableName
can static variables be accessed outside of the class without creating an pbject of that class
yes
where are static variables stored
stack
what is a java interface
the minimum methods that must be implemented for the object to be useful
example of making a class that uses an interface
public class Rectangle implements Shape
what is a constructor
a method which initialises an object
when are constructors invoked
object creation
if you don’t make a constructor what happens
java makes a deafult one for you, all attributes set to 0 or null
does constructor have a return type
no
what should constructor be called
same name as class
what is a constructor which takes in parameters called
parametrized constructor
what is constructor overloading
multiple constructors, each with different parameter lists needed to handle different cases
what does key word this refer to
current object
what is constructor chaining
reusing constructors from other classes
when using constructor chaining, in what psoition should the call to the constructor be in the method
first statement
what is inheritence
a new class is created using an existing classes methods, possibly adding more capabilities
benefits of inheritence
more efficient
cheaper
loss copying
in inheritance what is the parent class called
superclass
in inheritence what is the child class called
subclass
what is a direct subclass
inherits explicitly from superclass above
what is an indirect subclass
inherits from classes above the class above
in java, all classes have the superclass of what
Object
can you inherit from multiple classes into one class
no
are constructors inherited
no, must be called using super
methods inherited from the superclass must be….
overrided
how can superclass methods be accessed in a subclasss
using super.methodName( )
what is polymorphism
when many objects can be passed into the same method and at runtime, the program is able to establish which versions to use
(late binding)
what is upcasting
the typecasting of a child object to a parent object
what is an abstract class
a superclass from which other classes inherit and so they all have a common design
but none of its methods are functioning, so it cannot be used to instantiate objects
similar to an interface
what are concrete classes
classes which can be used to instantiate objects
a class which contains abstract methods must be a
n abstract class