Comp 1409 Pre-Midterm Flashcards
What is a Java Class and an example?
A file that describes a general category in terms of data and behaviours ie a book class describes title, author, date written, that the book can be opened and closed etc
What is an object?
One specific instance of a class eg in a book class the object would be the title. Every book will have a title.
What are instance variables?
an individual piece of data within a class
nouns or adjectives should be used to describe what kind of data?
Instance variables
What are the 4 primitive data types?
int, double , boolean and char
What are the reference (or object) data types?
String and classes
What are 2 visibility modifiers (access modifiers) from lesson 2?
public or private, accessible from any class or only from within a class
instance variables should always be be private?
True
What is a constructor and and what does it do?
A constructor is a special method used to initialize objects when an object of a class is created (is called automatically). Is used to set sensible initial values for object attributes.
Constructors should be marked public
F
Constructors should have Javadoc comments
T with @param tags explainging each parameter’s conditions
What’s the difference between formal arguments and actual arguments
Formal arguments are instance variables in a constructor where as an actual argument is the data in the argument. IE formal argument is variable “title” where as the the actual argument would be “Star Wars”
What is a method?
An instruction, a function, a verb
How should methods be named?
As verbs
What must methods always have to compile?
a return type even if its void