Please enable JavaScript in your browser settings.
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 Description
Class Blueprint used to make an object
Object main building-block of java applications
Method Java word for function
Member variables variables defined in a class
2 main things in a class methods and member variables
Usually required to call a method? an object
start learning
start learning
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();
start learning
start learning
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
OO Object-Oriented
Subclass A child class of another class
Example of superclass and subclass Employee, Engineer
Method overriding Method in a subclass with same signature as superclass
Method overloading Method in a class with same name as another method
Keyword for subclassing MySuperclass extends MySubclass
What does a subclass inherit from superclass? methods (non-private) and member variables
start learning
start learning
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 Synonym
Superclass Parent class, Base class
Subclass Child class, Derived class
Function Method
Instance Object
Type Class
Member Member Variable
start learning
start learning
Classes
Question Answer
Abstract class Class 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 class A class that can't be subclassed
start learning
start learning
Methods
Question Answer
Static method Can be called without an object
Abstract method Method with no body
Name all access modifiers public private default (package) protected
Final method A method that can't be overridden
start learning
start learning
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
start learning
start learning
Primitive Description
boolean 1 bit (true or false)
char 2 byte unicode character (0 to 216 -1)
byte 1 byte integer (-27 to 27 -1)
short 2 byte integer (-215 to 215 -1)
int 4 byte integer (-231 to 231 -1)
long 8 byte integer (-263 to 263 -1)
float 4 byte floating point
double 8 byte floating point
start learning
start learning
Character Escape Codes
Escape Code Description
\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
start learning
start learning
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
start learning
start learning
Advanced
Question Answer
Name all modifiers access : private, default (package), protected, publicnon-access: static abstract final synchronized native strictfp transient volatile
start learning
start learning