Memorize.com

Scjp

edit

Summary

Questions for the Java Programmer Cert, Section 1 (Declarations, Initialization and Scoping).

Exam Objectives - Section 1

Listed at the #objectives
On Sun's site
http://www.sun.com/training/catalog/courses/CX-310-055.xml"

Basics

Term (memorize) Description (memorize)
ClassBlueprint used to make an object
Objectmain building-block of java applications
MethodJava word for function
Member variablesvariables defined in a class
2 main things in a classmethods and member variables
Usually required to call a method?an object

Basic Code

Question (memorize) Answer (memorize)
Define a class
class MyClass {
// Members
// Methods
}
Define a method
void myMethod() {
// Body
}
Define a member
int i;
Define a main() method
public static void main( String[] args ) {
// Body
}
Create an object
MyClass myObject = new MyClass();
Call a method
myObject.myMethod();

Object-Oriented concepts

Java is a thoroughly object-oriented language. Objects are the primary building blocks of Java applications. You can think of objects as containers for variables and methods (functions). When speaking at a high level, "object" and "class" are sometimes used interchangably, even though a class is a definition used to create an object.

 

Question (memorize) Answer (memorize)
OOObject-Oriented
SubclassA child class of another class
Example of superclass and subclassEmployee, Engineer
Method overridingMethod in a subclass with same signature as superclass
Method overloadingMethod in a class with same name as another method
Keyword for subclassingMySuperclass extends MySubclass
What does a subclass inherit from superclass?methods (non-private) and member variables

Synonyms

Synonyms are rampant in the Java world. For example, it isn't uncommon for someone to use "object" and "instance" in the same sentence to refer to the same thing. This can be confusing to newbies.

 

Term (memorize) Synonym (memorize)
SuperclassParent class, Base class
SubclassChild class, Derived class
FunctionMethod
InstanceObject
TypeClass
MemberMember Variable

Classes

Question (memorize) Answer (memorize)
Abstract classClass that can't be instantiated
What is a top-level class?A class not defined within another class
Modifiers allowed for a top-level class?public, abstract, final
Final classA class that can't be subclassed

Methods

Question (memorize) Answer (memorize)
Static methodCan be called without an object
Abstract methodMethod with no body
Name all access modifierspublic
private
default (package)
protected
Final methodA method that can't be overridden

Types

Question (memorize) Answer (memorize)
All integer types are...signed
In Java, variables are either...- references to objects - or, primitive types
Name all primitive types- boolean, char - byte, short, int, long - float double

 

Primitive (memorize) Description (memorize)
boolean1 bit (true or false)
char2 byte unicode character (0 to 216-1)
byte1 byte integer (-27 to 27-1)
short2 byte integer (-215 to 215-1)
int4 byte integer (-231 to 231-1)
long8 byte integer (-263 to 263-1)
float4 byte floating point
double8 byte floating point

Character Escape Codes

Escape Code (memorize) Description (memorize)
\n New line
\t Tab
\b Backspace
\r Carriage return
\f Formfeed
\\ Backslash
\' Single quotation mark
\" Double quotation mark
\d Octal
\xd Hexadecimal
\ud Unicode character

Gotcha's

Question (memorize) Answer (memorize)
Can a class be static?Yes, but only an inner class
Can a non-abstract class have an abstract method?no
Can an abstract class have a non-abstract method?yes

Advanced

Question (memorize) Answer (memorize)
Name all modifiersaccess: private, default (package), protected, public
non-access:
static
abstract
final
synchronized
native
strictfp
transient
volatile