CMPS 161/280 Flashcards
What is an Object?
a self-contained component that contains properties and methods needed to make a certain type of data useful. An object’s properties are what it know and its methods are what it can do.
What is a Class?
a blueprint or template or set of instructions to build a specific type of object. Every object is built from a class.
What is instantiation?
Give an example.
The process of a class being used to create an object. SimpsonsCharacter bart = new SimpsonsCharacter();
What does the Public access modifier mean?
Any class can refer to the field or call the method.
What does the Private access modifier mean?
Only the current class will have access to the field or method.
What does the Protected access modifier mean?
Only the current class and subclasses of this class will have access to the field or method.
What is a Method?
What is the syntax for a Method?
Syntax: {access} {use} {return type} methodName({parameters})
Behavior of objects are represented as methods. methodName(parameters) { method body; }
What are the return types for a method?
Int, String, Boolean, Object, void?
What is a static method?
Static methods are meant to be relevant to all instances of a class rather than to any specific instance. They are called “static” because they are resolved at compile time based on the class they are called on. They can’t be overriden.
Considering Arguments, what is Pass by Value?
Making a copy in memory of the actual parameter’s value that is passed in, a copy of the contents of the actual parameter.
Considering arguments, what is Pass by Reference?
A copy of the address of the actual parameter is stored. Use pass by reference when you are changing the parameter passed in by the client program.
What are the 8 basic data types in Java?
byte, short, int, long, float, double, boolean, char
What is the Byte data type?
Byte data type is an 8-bit signed two’s complement integer.
Minimum value is -128 (-2^7)
Maximum value is 127 (inclusive)(2^7 -1)
Example: byte a = 100 , byte b = -50
What is the Short data type?
Short data type is a 16-bit signed two’s complement integer.
Minimum value is -32,768 (-2^15)
Maximum value is 32,767 (inclusive) (2^15 -1)
Example: short s = 10000, short r = -20000
What is the int data type?
Int data type is a 32-bit signed two’s complement integer.
Minimum value is - 2,147,483,648.(-2^31)
Maximum value is 2,147,483,647(inclusive).(2^31 -1)
Example: int a = 100000, int b = -200000