Exam Questions And Answers Rated A+.
What is the difference between an object and a class? - Answer an object is an instance of a class
what is class decomposition? - Answer breaking a programming problem into multiple classes where
each class has a specific task to perform in solving the problem.
what are two characteristics of an object? - Answer - state (Variables)
- behaviour (Methods)
what does it mean to instantiate an object? - Answer using a class's constructor to create an instance
of an object.
in Java you use the keyword new.
example:
Student student = new Student("John", "Wayne");
what is a primitive data type and what are the 8 different ones? - Answer A value that is predefined by
the language and is named to a reserved keyword
- byte : 8 bit signed number variable
- short : 16 bit signed number variable
- int : 32 bit signed number variable
- long : 64 bit signed number variable
- float : 32 bit decimal value
- double : 64 bit decimal value
- boolean : true or false
- char : single character
, what is a parameter and what are the two types? - Answer a value that is passed to a method for it to
use.
formal and actual parameters
what is a formal parameter? - Answer parameters in the header of the method declaration are called
formal parameters and they are limited to the method they are declared in
what is an actual parameter? - Answer values passed into a method are called actual parameters or
arguments
what are advantages of object libraries? - Answer - code reusability
- complex algorithms do not need re-invention
- efficiency
what are disadvantages of OOP? - Answer - overly complex for simple problems
- tendency of over abstraction
what is aggregation? - Answer "has a" relationship between two classes where an object of one class
has an object of another.
example:
public class Classroom
{private Teacher teacher; // Classroom has a Teacher}
what are the advantages of modularity in program development? - Answer - productivity
- usability
- easily maintained
- code reusability
why should to dependencies between objects be reduced? - Answer because they decrease reusability