Create
Learn
Share

Scjp

rename
Updated 2007-06-06 23:14

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

TermDescription
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
memorize

Basic Code

Question Answer
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();
memorize

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 Answer
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
memorize

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.

 

TermSynonym
SuperclassParent class, Base class
SubclassChild class, Derived class
FunctionMethod
InstanceObject
TypeClass
MemberMember Variable
memorize

Classes

Question Answer
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
memorize

Methods

Question Answer
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
memorize

Types

Question Answer
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
memorize

 

PrimitiveDescription
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
memorize

Character Escape Codes

Escape CodeDescription
\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
memorize

Gotcha's

Question Answer
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
memorize

Advanced

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