<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6223315412069227645</id><updated>2011-07-29T01:58:35.893+02:00</updated><category term='SCJP'/><title type='text'>Java 5 In Action</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://java5inaction.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://java5inaction.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dmitry</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6223315412069227645.post-1461167204627830086</id><published>2006-11-29T17:02:00.000+02:00</published><updated>2006-11-29T17:05:01.887+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><title type='text'>SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 4)</title><content type='html'>&lt;h3&gt;Operators&lt;/h3&gt;&lt;h2&gt;Relational Operators&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Relational operators always result in a &lt;em&gt;boolean&lt;/em&gt; value (&lt;em&gt;true&lt;/em&gt;     or &lt;em&gt;false&lt;/em&gt;). &lt;/li&gt;  &lt;li&gt; There are six relational operators: &lt;em&gt;&amp;gt;, &amp;gt;=, &amp;lt;, &amp;lt;= , ==&lt;/em&gt;,     and &lt;em&gt;!=&lt;/em&gt;. The last two ( &lt;em&gt;==&lt;/em&gt; and &lt;em&gt;! =&lt;/em&gt; ) are sometimes     referred to as &lt;i class="emphasis"&gt;equality operators.&lt;/i&gt; &lt;/li&gt;  &lt;li&gt; When comparing characters, Java uses the Unicode value of the character     as the numerical value. &lt;/li&gt;  &lt;li&gt; Equality operators&lt;/p&gt;     &lt;ul&gt;      &lt;li&gt; There are two equality operators: == and !=. &lt;/li&gt;      &lt;li&gt; Four types of things can be tested: numbers, characters, booleans,         and reference variables. &lt;/li&gt;    &lt;/ul&gt;  &lt;/li&gt;  &lt;li&gt; When comparing reference variables, &lt;em&gt;==&lt;/em&gt; returns true only if both     references refer to the same object. &lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; Instanceof Operator&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; &lt;em&gt;instanceof&lt;/em&gt; is for reference variables only, and checks for whether     the object is of a particular type. &lt;/li&gt;  &lt;li&gt; The &lt;em&gt;instanceof&lt;/em&gt; operator can be used only to test objects (or &lt;em&gt;null&lt;/em&gt;)     against class types that are in the same class hierarchy. &lt;/li&gt;  &lt;li&gt; For interfaces, an object passes the &lt;em&gt;instanceof&lt;/em&gt; test if any of     its superclasses implement the interface on the right side of the &lt;em&gt;instanceof&lt;/em&gt;     operator. &lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; Arithmetic Operators&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; There are four primary math operators: add, subtract, multiply, and divide.   &lt;/li&gt;  &lt;li&gt; The remainder operator (%), returns the remainder of a division. &lt;/li&gt;  &lt;li&gt; Expressions are evaluated from left to right, unless you add parentheses,     or unless some operators in the expression have higher precedence than others.   &lt;/li&gt;  &lt;li&gt; The *, /, and % operators have higher precedence than &lt;b class="bold"&gt;+&lt;/b&gt;     and &lt;b class="bold"&gt;-&lt;/b&gt;. &lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; String Concatenation Operator&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; If either operand is a &lt;em&gt;string&lt;/em&gt;, the + operator concatenates the     operands. &lt;/li&gt;  &lt;li&gt; If both operands are numeric, the + operator adds the operands. &lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; Increment/Decrement Operators&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Prefix operators (++ and --) run before the value is used in the expression.   &lt;/li&gt;  &lt;li&gt; Postfix operators ( + + and --) run after the value is used in the expression.   &lt;/li&gt;  &lt;li&gt; In any expression, both operands are fully evaluated &lt;i class="emphasis"&gt;before&lt;/i&gt;     the operator is applied. &lt;/li&gt;  &lt;li&gt; Variables marked &lt;em&gt;final&lt;/em&gt; cannot be incremented or decremented. &lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; Ternary (Conditional Operator)&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Returns one of two values based on whether a &lt;em&gt;boolean&lt;/em&gt; expression     is &lt;em&gt;true&lt;/em&gt; or &lt;em&gt;false&lt;/em&gt;.&lt;/p&gt;     &lt;ul&gt;      &lt;li&gt; Returns the value after the ? if the expression is &lt;em&gt;true&lt;/em&gt;. &lt;/li&gt;      &lt;li&gt; Returns the value after the : if the expression is &lt;em&gt;false&lt;/em&gt;.       &lt;/li&gt;    &lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; Logical Operators&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; The exam covers six "logical" operators: &amp;amp;, |, ^, !, &amp;amp;&amp;amp;, and     | |. &lt;/li&gt;  &lt;li&gt; Logical operators work with two expressions (except for !) that must resolve     to &lt;em&gt;boolean&lt;/em&gt; values. &lt;/li&gt;  &lt;li&gt; The &amp;amp;&amp;amp; and &amp;amp; operators return &lt;em&gt;true&lt;/em&gt; only if both operands     are &lt;em&gt;true&lt;/em&gt;. &lt;/li&gt;  &lt;li&gt; The | | and | operators return &lt;em&gt;true&lt;/em&gt; if either or both operands     are &lt;em&gt;true&lt;/em&gt;. &lt;/li&gt;  &lt;li&gt; The &amp;amp;&amp;amp; and | | operators are known as short-circuit operators.   &lt;/li&gt;  &lt;li&gt; The &amp;amp;&amp;amp; operator does not evaluate the right operand if the left     operand is &lt;em&gt;false&lt;/em&gt;. &lt;/li&gt;  &lt;li&gt; The | | does not evaluate the right operand if the left operand is &lt;em&gt;true&lt;/em&gt;.   &lt;/li&gt;  &lt;li&gt; The &amp;amp; and | operators always evaluate both operands. &lt;/li&gt;  &lt;li&gt; The ^ operator (called the "logical XOR"), returns &lt;em&gt;true&lt;/em&gt; if exactly     one operand is &lt;em&gt;true&lt;/em&gt;. &lt;/li&gt;  &lt;li&gt; The ! operator (called the "inversion" operator), returns the opposite     value of the &lt;em&gt;boolean&lt;/em&gt; operand it precedes. &lt;/li&gt;&lt;/ul&gt;   &lt;div align="right"&gt;&lt;font size="-1"&gt;It is mostly from the &lt;a href="http://www.amazon.com/Certified-Programmer-310-055-Certification-Guides/dp/0072253606"&gt;McGraw    Hill - SCJP Sun Certified Programmer for Java 5 Study Guide&lt;/a&gt; &lt;/font&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6223315412069227645-1461167204627830086?l=java5inaction.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java5inaction.blogspot.com/feeds/1461167204627830086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6223315412069227645&amp;postID=1461167204627830086' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/1461167204627830086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/1461167204627830086'/><link rel='alternate' type='text/html' href='http://java5inaction.blogspot.com/2006/11/scjp-sun-certified-programmer-for-java_29.html' title='SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 4)'/><author><name>Dmitry</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6223315412069227645.post-6172791683886747744</id><published>2006-11-22T17:10:00.000+02:00</published><updated>2006-11-29T17:04:41.132+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><title type='text'>SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 3)</title><content type='html'>&lt;h3&gt;Assignments&lt;/h3&gt;&lt;h2&gt;Stack and Heap&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Local variables (method variables) live on the stack.&lt;/li&gt;  &lt;li&gt;Objects and their instance variables live on the heap.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Literals and Primitive Casting&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Integer literals can be decimal, octal (e.g. 013), or hexadecimal (e.g.     0x3d).&lt;/li&gt;  &lt;li&gt;Literals for longs end in L or 1.&lt;/li&gt;  &lt;li&gt;Float literals end in F or f, double literals end in a digit or D or d.&lt;/li&gt;  &lt;li&gt;The boolean literals are true and false.&lt;/li&gt;  &lt;li&gt;Literals for chars are a single character inside single quotes: 'd'.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Scope&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Scope refers to the lifetime of a variable.&lt;/li&gt;  &lt;li&gt;There are four basic scopes:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt;Static variables live basically as long as their class lives.&lt;/li&gt;    &lt;li&gt;Instance variables live as long as their object lives.&lt;/li&gt;    &lt;li&gt;Local variables live as long as their method is on the stack; however,       if their method invokes another method, they are temporarily unavailable.&lt;/li&gt;    &lt;li&gt;Block variables (e.g., in a for or an if) live until the block completes.&lt;/li&gt;  &lt;/ul&gt;&lt;/ul&gt;&lt;h2&gt;Basic Assignments&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Literal integers are implicitly ints.&lt;/li&gt;  &lt;li&gt;Integer expressions always result in an int-sized result, never smaller.&lt;/li&gt;  &lt;li&gt;Floating-point numbers are implicitly doubles (64 bits).&lt;/li&gt;  &lt;li&gt;Narrowing a primitive truncates the high order bits.&lt;/li&gt;  &lt;li&gt;Compound assignments (e.g. +=), perform an automatic cast.&lt;/li&gt;  &lt;li&gt;A reference variable holds the bits that are used to refer to an object.&lt;/li&gt;  &lt;li&gt;Reference variables can refer to subclasses of the declared type but not     to superclasses.&lt;/li&gt;  &lt;li&gt;When creating a new object, e.g., Button b = new Button();, three things     happen:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt;Make a reference variable named b, of type Button&lt;/li&gt;    &lt;li&gt;Create a new Button object&lt;/li&gt;    &lt;li&gt;Assign the Button object to the reference variable b &lt;/li&gt;  &lt;/ul&gt;&lt;/ul&gt;&lt;h2&gt;Using a Variable or Array Element That Is Uninitialized and Unassigned&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;When an array of objects is instantiated, objects within the array are not     instantiated automatically, but all the references get the default value of     null.&lt;/li&gt;  &lt;li&gt;When an array of primitives is instantiated, elements get default values.&lt;/li&gt;  &lt;li&gt;Instance variables are always initialized with a default value.&lt;/li&gt;  &lt;li&gt;Local/aufomatic/method variables are never given a default value. If you     attempt to use one before initializing it, you'll get a compiler error.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Passing Variables into Methods&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Methods can take primitives and/or object references as arguments.&lt;/li&gt;  &lt;li&gt;Method arguments are always copies.&lt;/li&gt;  &lt;li&gt;Method arguments are never actual objects (they can be references to objects).&lt;/li&gt;  &lt;li&gt;A primitive argument is an unattached copy of the original primitive.&lt;/li&gt;  &lt;li&gt;A reference argument is another copy of a reference to the original object.&lt;/li&gt;  &lt;li&gt;Shadowing occurs when two variables with different scopes share the same     name. This leads to hard-to-find bugs, and hard-to-answer exam questions.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Array Declaration, Construction, and Initialization&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Arrays can hold primitives or objects, but the array itself is always an     object.&lt;/li&gt;  &lt;li&gt;When you declare an array, the brackets can be left or right of the name.&lt;/li&gt;  &lt;li&gt;It is never legal to include the size of an array in the declaration.&lt;/li&gt;  &lt;li&gt;You must include the size of an array when you construct it (using new)     unless you are creating an anonymous array.&lt;/li&gt;  &lt;li&gt;Elements in an array of objects are not automatically created, although     primitive array elements are given default values.&lt;/li&gt;  &lt;li&gt;You'll get a NullPointerException if you try to use an array element in     an object array, if that element does not refer to a real object.&lt;/li&gt;  &lt;li&gt;Arrays are indexed beginning with zero.&lt;/li&gt;  &lt;li&gt;An ArraylndexOutOfBoundsException occurs if you use a bad index value.&lt;/li&gt;  &lt;li&gt;Arrays have a length variable whose value is the number of array elements.&lt;/li&gt;  &lt;li&gt;The last index you can access is always one less than the length of the     array.&lt;/li&gt;  &lt;li&gt;Multidimensional arrays are just arrays of arrays.&lt;/li&gt;  &lt;li&gt;The dimensions in a multidimensional array can have different lengths.&lt;/li&gt;  &lt;li&gt;An array of primitives can accept any value that can be promoted implicitly     to the array's declared type;. e.g., a byte variable can go in an int array.&lt;/li&gt;  &lt;li&gt;An array of objects can hold any object that passes the IS-A (or instanceof)     test for the declared type of the array. For example, if Horse extends Animal,     then a Horse object can go into an Animal array.&lt;/li&gt;  &lt;li&gt;If you assign an array to a previously declared array reference, the array     you're assigning must be the same dimension as the reference you're assigning     it to.&lt;/li&gt;  &lt;li&gt;You can assign an array of one type to a previously declared array reference     of one of its supertypes. For example, a Honda array can be assigned to an     array declared as type Car (assuming Honda extends Car).&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Initialization Blocks&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Static initialization blocks run once, when the class is first loaded.&lt;/li&gt;  &lt;li&gt;Instance initialization blocks run every time a new instance is created.     They run after all super-constructors and before the constructor's code has     run.&lt;/li&gt;  &lt;li&gt;If multiple init blocks exist in a class, they follow the rules stated above,     AND they run in the order in which they appear in the source file.&lt;/li&gt;&lt;/ul&gt;  &lt;h2&gt;Using Wrappers (Objective 3.1)&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;The wrapper classes correlate to the primitive types.&lt;/li&gt;   &lt;li&gt;Wrappers have two main functions:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; To wrap primitives so that they can be handled like objects&lt;/li&gt;    &lt;li&gt;To provide utility methods for primitives (usually conversions)&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt;The three most important method families are&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt;xxxValue() Takes no arguments, returns a primitive&lt;/li&gt;    &lt;li&gt; parseXxx() Takes a String, returns a primitive, throws NFE&lt;/li&gt;    &lt;li&gt; valueOf() Takes a String, returns a wrapped object, throws NFE&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt;Wrapper constructors can take a String or a primitive, except for Character,     which can only take a char.&lt;/li&gt;  &lt;li&gt;Radix refers to bases (typically) other than 10; octal is radix = 8, hex     = 16.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Boxing&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;As of Java 5, boxing allows you to convert primitives to wrappers or to     convert wrappers to primitives automatically.&lt;/li&gt;  &lt;li&gt;Using = = with wrappers is tricky; wrappers with the same small values (typically     lower than 127), will be = =, larger values will not be = =.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Advanced Overloading&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Primitive widening uses the "smallest" method argument possible.&lt;/li&gt;  &lt;li&gt;Used individually, boxing and var-args are compatible with overloading.&lt;/li&gt;  &lt;li&gt;You CANNOT widen from one wrapper type to another. (IS-A fails.)&lt;/li&gt;  &lt;li&gt;You CANNOT widen and then box. (An int can't become a Long.)&lt;/li&gt;  &lt;li&gt;You can box and then widen. (An int can become an Object, via an Integer.)&lt;/li&gt;  &lt;li&gt;You can combine var-args with either widening or boxing.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Garbage Collection&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;In Java, garbage collection (GC) provides automated memory management.&lt;/li&gt;  &lt;li&gt;The purpose of GC is to delete objects that can't be reached.&lt;/li&gt;  &lt;li&gt;Only the JVM decides when to run the GC, you can only suggest it.&lt;/li&gt;  &lt;li&gt;You can't know the GC algorithm for sure.&lt;/li&gt;  &lt;li&gt;Objects must be considered eligible before they can be garbage collected.&lt;/li&gt;  &lt;li&gt;An object is eligible when no live thread can reach it.&lt;/li&gt;  &lt;li&gt;To reach an object, you must have a live, reachable reference to that object.&lt;/li&gt;  &lt;li&gt;Java applications can run out of memory.&lt;/li&gt;  &lt;li&gt;Islands of objects can be GCed, even though they refer to each other.&lt;/li&gt;  &lt;li&gt;Request garbage collection with System.gc(); (recommended).&lt;/li&gt;  &lt;li&gt;Class Object has a finalize() method.&lt;/li&gt;  &lt;li&gt;The finalize() method is guaranteed to run once and only once before the     garbage collector deletes an object.&lt;/li&gt;  &lt;li&gt;The garbage collector makes no guarantees, finalize() may never run.&lt;/li&gt;  &lt;li&gt;You can uneligibilize an object for GC from within finalize().&lt;/li&gt;&lt;/ul&gt;&lt;div align="right"&gt;&lt;font size="-1"&gt;It is mostly from the   &lt;a href="http://www.amazon.com/Certified-Programmer-310-055-Certification-Guides/dp/0072253606"&gt;McGraw   Hill - SCJP Sun Certified Programmer for Java 5 Study Guide&lt;/a&gt; &lt;/font&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6223315412069227645-6172791683886747744?l=java5inaction.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java5inaction.blogspot.com/feeds/6172791683886747744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6223315412069227645&amp;postID=6172791683886747744' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/6172791683886747744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/6172791683886747744'/><link rel='alternate' type='text/html' href='http://java5inaction.blogspot.com/2006/11/scjp-sun-certified-programmer-for-java_22.html' title='SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 3)'/><author><name>Dmitry</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6223315412069227645.post-8817653715797626022</id><published>2006-11-10T22:01:00.001+02:00</published><updated>2006-11-22T17:22:35.426+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><title type='text'>SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 2)</title><content type='html'>&lt;h3&gt;Object Orientation &lt;/h3&gt;&lt;h2&gt;Encapsulation, IS-A, HAS-A&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Encapsulation helps hide implementation behind an interface (or API).&lt;/li&gt;  &lt;li&gt; Encapsulated code has two features:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; Instance variables are kept protected (usually with the private modifier).&lt;/li&gt;    &lt;li&gt; Getter and setter methods provide access to instance variables.&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; IS-A refers to inheritance.&lt;/li&gt;  &lt;li&gt; IS-A is expressed with the keyword &lt;em&gt;extends&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt; IS-A, "inherits from," and "is a subtype of" are all equivalent expressions.&lt;/li&gt;  &lt;li&gt; HAS-A means an instance of one class "has a" reference to an instance of     another class or another instance of the same class.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Inheritance&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Inheritance allows a class to be a subclass of a superclass, and thereby     inherit &lt;em&gt;public&lt;/em&gt; and &lt;em&gt;protected&lt;/em&gt; variables and methods of the     superclass.&lt;/li&gt;  &lt;li&gt; Inheritance is a key concept that underlies IS-A, polymorphism, overriding,     overloading, and casting.&lt;/li&gt;  &lt;li&gt; All classes (except class &lt;em&gt;object&lt;/em&gt;), are subclasses of type &lt;em&gt;object&lt;/em&gt;,     and therefore they inherit &lt;em&gt;object&lt;/em&gt;'s methods.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Polymorphism&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Polymorphism means "many forms."&lt;/li&gt;  &lt;li&gt; A reference variable is always of a single, unchangeable type, but it can     refer to a subtype object.&lt;/li&gt;  &lt;li&gt; A single object can be referred to by reference variables of many different     types&amp;mdash;as long as they are the same type or a supertype of the object.&lt;/li&gt;  &lt;li&gt; The reference variable's type (not the object's type), determines which     methods can be called!&lt;/li&gt;  &lt;li&gt; Polymorphic method invocations apply only to overridden instance methods.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Overriding and Overloading&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Methods can be overridden or overloaded; constructors can be overloaded     but not overridden.&lt;/li&gt;  &lt;li&gt; Abstract methods must be overridden by the first concrete (non-abstract)     Subclass.&lt;/li&gt;  &lt;li&gt; With respect to the method it overrides, the overriding method&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; Must have the same argument list.&lt;/li&gt;    &lt;li&gt; Must have the same return type, except that as of Java 5, the return       type can be a subclass&amp;mdash;this is known as a covariant return.&lt;/li&gt;    &lt;li&gt; Must not have a more restrictive access modifier.&lt;/li&gt;    &lt;li&gt; May have a less restrictive access modifier.&lt;/li&gt;    &lt;li&gt; Must not throw new or broader checked exceptions.&lt;/li&gt;    &lt;li&gt; May throw fewer or narrower checked exceptions, or any unchecked exception.&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; final methods cannot be overridden.&lt;/li&gt;  &lt;li&gt; Only inherited methods may be overridden, and remember that private methods     are not inherited.&lt;/li&gt;  &lt;li&gt; A subclass uses super.overriddenMethodName() to call the superclass version     of an overridden method.&lt;/li&gt;  &lt;li&gt; Overloading means reusing a method name, but with different arguments.&lt;/li&gt;  &lt;li&gt; Overloaded methods&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; Must have different argument lists&lt;/li&gt;    &lt;li&gt; May have different return types, if argument lists are also different&lt;/li&gt;    &lt;li&gt; May have different access modifiers&lt;/li&gt;    &lt;li&gt; May throw different exceptions&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; Methods from a superclass can be overloaded in a subclass.&lt;/li&gt;  &lt;li&gt; Polymorphism applies to overriding, not to overloading.&lt;/li&gt;  &lt;li&gt; Object type (not the reference variable's type), determines which overridden     method is used at runtime.&lt;/li&gt;  &lt;li&gt; Reference type determines which overloaded method will be used at compile     time.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Reference Variable Casting&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; There are two types of reference variable casting: downcasting and upcasting.&lt;/li&gt;  &lt;li&gt; Downcasting: If you have a reference variable that refers to a subtype     object, you can assign it to a reference variable of the subtype. You must     make an explicit cast to do this, and the result is that you can access the     subtype's members with this new reference variable.&lt;/li&gt;  &lt;li&gt; Upcasting: You can assign a reference variable to a supertype reference     variable explicitly or implicitly. This is an inherently safe operation because     the assignment restricts the access capabilities of the new variable.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Implementing an Interface&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; When you implement an interface, you are fulfilling its contract.&lt;/li&gt;  &lt;li&gt; You implement an interface by properly and concretely overriding all of     the methods defined by the interface.&lt;/li&gt;  &lt;li&gt; A single class can implement many interfaces.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Return Types&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Overloaded methods can change return types; overridden methods cannot,     except in the case of covariant returns.&lt;/li&gt;  &lt;li&gt; Object reference return types can accept null as a return value.&lt;/li&gt;  &lt;li&gt; An array is a legal return type, both to declare and return as a value.&lt;/li&gt;  &lt;li&gt; For methods with primitive return types, any value that can be implicitly     converted to the return type can be returned.&lt;/li&gt;  &lt;li&gt; Nothing can be returned from a void, but you can return nothing. You're     allowed to simply say return, in any method with a void return type, to bust     out of a method early. But you can't return nothing from a method with a non-void     return type.&lt;/li&gt;  &lt;li&gt; Methods with an object reference return type, can return a subtype.&lt;/li&gt;  &lt;li&gt; Methods with an interface return type, can return any implementer.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Constructors and Instantiation&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; A constructor is always invoked when a new object is created.&lt;/li&gt;  &lt;li&gt; Each superclass in an object's inheritance tree will have a constructor     called.&lt;/li&gt;  &lt;li&gt; Every class, even an abstract class, has at least one constructor.&lt;/li&gt;  &lt;li&gt; Constructors must have the same name as the class.&lt;/li&gt;  &lt;li&gt; Constructors don't have a return type. If you see code with a return type,     it's a method with the same name as the class, it's not a constructor.&lt;/li&gt;  &lt;li&gt; Typical constructor execution occurs as follows:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; The constructor calls its superclass constructor, which calls its superclass       constructor, and so on all the way up to the Object constructor.&lt;/li&gt;    &lt;li&gt; The Object constructor executes and then returns to the calling constructor,       which runs to completion and then returns to its calling constructor, and       so on back down to the completion of the constructor of the actual instance       being created.&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; Constructors can use any access modifier (even private!).&lt;/li&gt;  &lt;li&gt; The compiler will create a default constructor if you don't create any     constructors in your class.&lt;/li&gt;  &lt;li&gt; The default constructor is a no-arg constructor with a no-arg call to super().&lt;/li&gt;  &lt;li&gt; The first statement of every constructor must be a call to either this()     (an overloaded constructor) or super().&lt;/li&gt;  &lt;li&gt; The compiler will add a call to super() unless you have already put in     a call to this() or super().&lt;/li&gt;  &lt;li&gt; Instance members are accessible only after the super constructor runs.&lt;/li&gt;  &lt;li&gt; Abstract classes have constructors that are called when a concrete subclass     is instantiated.&lt;/li&gt;  &lt;li&gt; Interfaces do not have constructors.&lt;/li&gt;  &lt;li&gt; If your superclass does not have a no-arg constructor, you must create     a constructor and insert a call to super() with arguments matching those of     the superclass constructor.&lt;/li&gt;  &lt;li&gt; Constructors are never inherited, thus they cannot be overridden.&lt;/li&gt;  &lt;li&gt; A constructor can be directly invoked only by another constructor (using     acall to super() or this()).&lt;/li&gt;  &lt;li&gt; Issues with calls to this() &lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; May appear only as the first statement in a constructor.&lt;/li&gt;    &lt;li&gt; The argument list determines which overloaded constructor is called.&lt;/li&gt;    &lt;li&gt; Constructors can call constructors can call constructors, and so on,       but sooner or later one of them better call super() or the stack will explode.&lt;/li&gt;    &lt;li&gt; Calls to this() and super() cannot be in the same constructor. You can       have one or the other, but never both.&lt;/li&gt;  &lt;/ul&gt;&lt;/ul&gt;&lt;h2&gt;Statics&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Use static methods to implement behaviors that are not affected by the     state of any instances.&lt;/li&gt;  &lt;li&gt; Use static variables to hold data that is class specific as opposed to     instance specific&amp;mdash;there will be only one copy of a static variable.&lt;/li&gt;  &lt;li&gt; All static members belong to the class, not to any instance.&lt;/li&gt;  &lt;li&gt; A static method can't access an instance variable directly.&lt;/li&gt;  &lt;li&gt; Use the dot operator to access static members, but remember that using     a reference variable with the dot operator is really a syntax trick, and the     compiler will substitute the class name for the reference variable, for instance     d.doStuff(); becomes: Dog.doStuff();&lt;/li&gt;  &lt;li&gt; static methods can't be overridden, but they can be redefined.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt; Coupling and Cohesion&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Coupling refers to the degree to which one class knows about or uses members     of another class.&lt;/li&gt;  &lt;li&gt; Loose coupling is the desirable state of having classes that are well encapsulated,     minimize references to each other, and limit the breadth of API usage.&lt;/li&gt;  &lt;li&gt; Tight coupling is the undesirable state of having classes that break the     rules of loose coupling.&lt;/li&gt;  &lt;li&gt; Cohesion refers to the degree in which a class has a single, well-defined     role or responsibility.&lt;/li&gt;  &lt;li&gt; High cohesion is the desirable state of a class whose members support a     single, well-focused role or responsibility.&lt;/li&gt;  &lt;li&gt; Low cohesion is the undesirable state of a class whose members support     multiple, unfocused roles or responsibilities.&lt;/li&gt;&lt;/ul&gt;&lt;div align="right"&gt;&lt;font size="-1"&gt;It is mostly from the   &lt;a href="http://www.amazon.com/Certified-Programmer-310-055-Certification-Guides/dp/0072253606"&gt;McGraw   Hill - SCJP Sun Certified Programmer for Java 5 Study Guide&lt;/a&gt; &lt;/font&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6223315412069227645-8817653715797626022?l=java5inaction.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java5inaction.blogspot.com/feeds/8817653715797626022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6223315412069227645&amp;postID=8817653715797626022' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/8817653715797626022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/8817653715797626022'/><link rel='alternate' type='text/html' href='http://java5inaction.blogspot.com/2006/11/scjp-sun-certified-programmer-for-java_10.html' title='SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 2)'/><author><name>Dmitry</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6223315412069227645.post-5773697311825514905</id><published>2006-11-10T19:30:00.000+02:00</published><updated>2006-11-14T20:01:01.464+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><title type='text'>SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 1)</title><content type='html'>&lt;p&gt;So, now I'm preparing for the SCJP5. I've got a perfect book for this &amp;#8211;   "&lt;a href="http://www.amazon.com/Certified-Programmer-310-055-Certification-Guides/dp/0072253606"&gt;McGraw   Hill - SCJP Sun Certified Programmer for Java 5 Study Guide&lt;/a&gt;". There is a   Short Drill in the end of every chapter. I post them (drills) with some additional   information/comments. I hope it will be helpful for you guys.&lt;/p&gt;&lt;h3&gt;Declarations and Access Control&lt;/h3&gt;&lt;h2&gt;Identifiers&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Identifiers can begin with a letter, an underscore, or a currency character.&lt;/li&gt;  &lt;li&gt; After the first character, identifiers can also include digits.&lt;/li&gt;  &lt;li&gt; Identifiers can be of any length.&lt;/li&gt;  &lt;li&gt; JavaBeans methods must be named using camelCase, and depending on the method's     purpose, must start with &lt;em&gt;set, get, is, add&lt;/em&gt;, or &lt;em&gt;remove&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt;Java Keywords: &lt;em&gt;abstract, boolean, break, byte, case, catch, char, class,     const, continue, default, do, double, else, extends, final, finally, float,     for, goto, if, implements, import, instanceof, int, interface, long, native,     new, package, private, protected, public, return, short, static, strictfp,     super, switch, synchronized, this, throw, throws, transient, try, void, volatile,     while, assert, enum&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Declaration Rules&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;A source code file can have only one &lt;em&gt;public&lt;/em&gt; class.&lt;/li&gt;  &lt;li&gt;If the source file contains a &lt;em&gt;public&lt;/em&gt; class, the filename must match     the &lt;em&gt;public&lt;/em&gt; class name.&lt;/li&gt;  &lt;li&gt;A file can have only one &lt;em&gt;package&lt;/em&gt; statement, but multiple &lt;em&gt;imports&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt;The &lt;em&gt;package&lt;/em&gt; statement (if any) must be the first (non-comment)     line in a source file.&lt;/li&gt;  &lt;li&gt;The &lt;em&gt;import&lt;/em&gt; statements (if any) must come after the package and     before the class declaration.&lt;/li&gt;  &lt;li&gt;If there is no package statement, &lt;em&gt;import&lt;/em&gt; statements must be the     first (non-comment) statements in the source file.&lt;/li&gt;  &lt;li&gt;&lt;em&gt;package&lt;/em&gt; and &lt;em&gt;import&lt;/em&gt; statements apply to all classes in     the file.&lt;/li&gt;  &lt;li&gt;A file can have more than one nonpublic class.&lt;/li&gt;  &lt;li&gt;Files with no &lt;em&gt;public&lt;/em&gt; classes have no naming restrictions.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Class Access Modifiers&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;There are three access modifiers: &lt;em&gt;public&lt;/em&gt;, &lt;em&gt;protected&lt;/em&gt;, and     &lt;em&gt;private&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt; There are four access levels: public, protected, default, and private.&lt;/li&gt;  &lt;li&gt; Classes can have only &lt;em&gt;public&lt;/em&gt; or &lt;em&gt;default&lt;/em&gt; access.&lt;/li&gt;  &lt;li&gt; A class with &lt;em&gt;default&lt;/em&gt; access can be seen only by classes within     the same package.&lt;/li&gt;  &lt;li&gt; A class with &lt;em&gt;public&lt;/em&gt; access can be seen by all classes from all     packages.&lt;/li&gt;  &lt;li&gt; Class visibility revolves around whether code in one class can: &lt;/li&gt;  &lt;ul&gt;    &lt;li&gt;Create an instance of another class &lt;/li&gt;    &lt;li&gt;Extend (or subclass), another class &lt;/li&gt;    &lt;li&gt;Access methods and variables of another class&lt;/li&gt;  &lt;/ul&gt;&lt;/ul&gt;&lt;h2&gt;Class Modifiers (Nonaccess)&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Classes can also be modified with &lt;em&gt;final&lt;/em&gt;, &lt;em&gt;abstract&lt;/em&gt;, or     &lt;em&gt;strictfp&lt;/em&gt;. &lt;/li&gt;  &lt;li&gt; A class cannot be both &lt;em&gt;final&lt;/em&gt; and &lt;em&gt;abstract&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt;A &lt;em&gt;final&lt;/em&gt; class cannot be subclassed.&lt;/li&gt;  &lt;li&gt; An &lt;em&gt;abstract&lt;/em&gt; class cannot be instantiated.&lt;/li&gt;  &lt;li&gt;A single &lt;em&gt;abstract&lt;/em&gt; method in a class means the whole class must     be &lt;em&gt;abstract&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt;An &lt;em&gt;abstract&lt;/em&gt; class can have both &lt;em&gt;abstract&lt;/em&gt; and nonabstract     methods.&lt;/li&gt;  &lt;li&gt; The first concrete class to extend an &lt;em&gt;abstract&lt;/em&gt; class must implement     all of its &lt;em&gt;abstract&lt;/em&gt; methods.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Interface Implementation&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt;Interfaces are contracts for what a class can do, but they say nothing about     the way in which the class must do it.&lt;/li&gt;  &lt;li&gt;Interfaces can be implemented by any class, from any inheritance tree.&lt;/li&gt;  &lt;li&gt;An interface is like a 100-percent &lt;em&gt;abstract&lt;/em&gt; class, and is implicitly     &lt;em&gt;abstract&lt;/em&gt; whether you type the &lt;em&gt;abstract&lt;/em&gt; modifier in the declaration     or not.&lt;/li&gt;  &lt;li&gt;An interface can have only &lt;em&gt;abstract&lt;/em&gt; methods, no concrete methods     allowed.&lt;/li&gt;  &lt;li&gt;Interface methods are by &lt;em&gt;default&lt;/em&gt; &lt;em&gt;public&lt;/em&gt; and &lt;em&gt;abstract&lt;/em&gt;&amp;#8212;explicit     declaration of these modifiers is optional.&lt;/li&gt;  &lt;li&gt;Interfaces can have constants, which are always implicitly &lt;em&gt;public&lt;/em&gt;,     &lt;em&gt;static&lt;/em&gt;, and &lt;em&gt;final&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt;Interface constant declarations of &lt;em&gt;public&lt;/em&gt;, &lt;em&gt;static&lt;/em&gt;, and     &lt;em&gt;final&lt;/em&gt; are optional in any combination.&lt;/li&gt;  &lt;li&gt;A legal nonabstract implementing class has the following properties:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt;It provides concrete implementations for the interface's methods.&lt;/li&gt;    &lt;li&gt;It must follow all legal override rules for the methods it implements.&lt;/li&gt;    &lt;li&gt;It must not declare any new checked exceptions for an implementation method.&lt;/li&gt;    &lt;li&gt;It must not declare any checked exceptions that are broader than the exceptions       declared in the interface method.&lt;/li&gt;    &lt;li&gt;It may declare runtime exceptions on any interface method implementation       regardless of the interface declaration.&lt;/li&gt;    &lt;li&gt;It must maintain the exact signature (allowing for covariant returns)       and return type of the methods it implements (but does not have to declare       the exceptions of the interface).&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; A class implementing an interface can itself be &lt;em&gt;abstract&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt; An &lt;em&gt;abstract&lt;/em&gt;, implementing class docs not have to implement the     interface methods (but the first concrete subclass must).&lt;/li&gt;  &lt;li&gt; A class can extend only one class (no multiple inheritance), but it can     implement many interfaces.&lt;/li&gt;  &lt;li&gt; Interfaces can extend one or more other interfaces.&lt;/li&gt;  &lt;li&gt; Interfaces cannot extend a class, or implement a class or interface.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Member Access Modifiers&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Methods and instance (nonlocal) variables are known as &amp;quot;members. &amp;quot;&lt;/li&gt;  &lt;li&gt; Members can use all four access levels: &lt;em&gt;public&lt;/em&gt;, &lt;em&gt;protected&lt;/em&gt;,     &lt;em&gt;default&lt;/em&gt;, &lt;em&gt;private&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt; Member access comes in two forms:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; Code in one class can access a member of another class.&lt;/li&gt;    &lt;li&gt; A subclass can inherit a member of its superclass.&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; If a class cannot be accessed, its members cannot be accessed.&lt;/li&gt;  &lt;li&gt; Determine class visibility before determining member visibility.&lt;/li&gt;  &lt;li&gt; &lt;em&gt;public&lt;/em&gt; members can be accessed by all other classes, even in other     packages.&lt;/li&gt;  &lt;li&gt; If a superclass member is &lt;em&gt;public&lt;/em&gt;, the subclass inherits it&amp;#8212;regardless     of package.&lt;/li&gt;  &lt;li&gt; Members accessed without the dot operator (.) must belong to the same class.&lt;/li&gt;  &lt;li&gt; this. always refers to the currently executing object.&lt;/li&gt;  &lt;li&gt; this.aMethod() is the same as just invoking aMethod().&lt;/li&gt;  &lt;li&gt; &lt;em&gt;private&lt;/em&gt; members can be accessed only by code in the same class.&lt;/li&gt;  &lt;li&gt; &lt;em&gt;private&lt;/em&gt; members are not visible to subclasses, so &lt;em&gt;private&lt;/em&gt;     members can not be inherited.&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; &lt;em&gt;default&lt;/em&gt; and &lt;em&gt;protected&lt;/em&gt; members differ only when subclasses       are involved:&lt;/li&gt;    &lt;li&gt;&lt;em&gt;default&lt;/em&gt; members can be accessed only by classes in the same package.&lt;/li&gt;    &lt;li&gt; &lt;em&gt;protected&lt;/em&gt; members can be accessed by other classes in the same       package, plus subclasses regardless of package.&lt;/li&gt;    &lt;li&gt; &lt;em&gt;protected&lt;/em&gt; = package plus kids (kids meaning subclasses).&lt;/li&gt;    &lt;li&gt; For subclasses outside the package, the &lt;em&gt;protected&lt;/em&gt; member can       be accessed only through inheritance; a subclass outside the package cannot       access a &lt;em&gt;protected&lt;/em&gt; member by using a reference to a superclass       instance (in other words, inheritance is the only mechanism for a subclass       outside the package to access a &lt;em&gt;protected&lt;/em&gt; member of its superclass).&lt;/li&gt;    &lt;li&gt; A &lt;em&gt;protected&lt;/em&gt; member inherited by a subclass from another package       is not accessible to any other class in the subclass package, except for       the subclass' own subclasses.&lt;/li&gt;  &lt;/ul&gt;&lt;/ul&gt;&lt;h2&gt;Local Variables&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Local (method, automatic, or stack) variable declarations cannot have access     modifiers.&lt;/li&gt;  &lt;li&gt; &lt;em&gt;final&lt;/em&gt; is the only modifier available to local variables.&lt;/li&gt;  &lt;li&gt; Local variables don't get &lt;em&gt;default&lt;/em&gt; values, so they must be initialized     before use.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Other Modifiers&amp;#8212;Members&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; &lt;em&gt;final&lt;/em&gt; methods cannot be overridden in a subclass.&lt;/li&gt;  &lt;li&gt; &lt;em&gt;abstract&lt;/em&gt; methods are declared, with a signature, a return type,     and an optional throws clause, but are not implemented.&lt;/li&gt;  &lt;li&gt; &lt;em&gt;abstract&lt;/em&gt; methods end in a semicolon&amp;#8212;no curly braces.&lt;/li&gt;  &lt;li&gt; Three ways to spot a non-&lt;em&gt;abstract&lt;/em&gt; method:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; The method is not marked &lt;em&gt;abstract&lt;/em&gt;.&lt;/li&gt;    &lt;li&gt; The method has curly braces.&lt;/li&gt;    &lt;li&gt; The method has code between the curly braces.&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; The first non&lt;em&gt;abstract&lt;/em&gt; (concrete) class to extend an &lt;em&gt;abstract&lt;/em&gt;     class must implement all of the &lt;em&gt;abstract&lt;/em&gt; class' &lt;em&gt;abstract&lt;/em&gt;     methods.&lt;/li&gt;  &lt;li&gt; The synchronized modifier applies only to methods and code blocks.&lt;/li&gt;  &lt;li&gt; synchronized methods can have any access control and can also be marked     &lt;em&gt;final&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt; &lt;em&gt;abstract&lt;/em&gt; methods must be implemented by a subclass, so they must     be inheritable. For that reason:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; &lt;em&gt;abstract&lt;/em&gt; methods cannot be &lt;em&gt;private&lt;/em&gt;.&lt;/li&gt;    &lt;li&gt; &lt;em&gt;abstract&lt;/em&gt; methods cannot be &lt;em&gt;final&lt;/em&gt;.&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; The &lt;em&gt;native&lt;/em&gt; modifier applies only to methods.&lt;/li&gt;  &lt;li&gt; The &lt;em&gt;strictfp&lt;/em&gt; modifier applies only to classes and methods.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Methods with Var-args &lt;sup&gt;&lt;font size="-1"&gt;*NEW&lt;/font&gt;&lt;/sup&gt;&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; As of Java 5, methods can declare a parameter that accepts from zero to     many arguments, a so-called var-arg method.&lt;/li&gt;  &lt;li&gt; A var-arg parameter is declared with the syntax type... name; for instance:     doStuff(int... x) { } &lt;/li&gt;  &lt;li&gt; A var-arg method can have only one var-arg parameter.&lt;/li&gt;  &lt;li&gt; In methods with normal parameters and a var-arg, the var-arg must come     last.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Variable Declarations&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Instance variables can&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; Have any access control&lt;/li&gt;    &lt;li&gt; Be marked &lt;em&gt;final&lt;/em&gt; or transient&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; Instance variables can't be &lt;em&gt;abstract&lt;/em&gt;, synchronized, &lt;em&gt;native&lt;/em&gt;,     or &lt;em&gt;strictfp&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt; It is legal to declare a local variable with the same name as an instance     variable; this is called &amp;quot;shadowing.&amp;quot;&lt;/li&gt;  &lt;li&gt; &lt;em&gt;final&lt;/em&gt; variables have the following properties:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt; &lt;em&gt;final&lt;/em&gt; variables cannot be reinitialized once assigned a value.&lt;/li&gt;    &lt;li&gt; &lt;em&gt;final&lt;/em&gt; reference variables cannot refer to a different object       once the object has been assigned to the &lt;em&gt;final&lt;/em&gt; variable.&lt;/li&gt;    &lt;li&gt; &lt;em&gt;final&lt;/em&gt; reference variables must be initialized before the constructor       completes.&lt;/li&gt;  &lt;/ul&gt;  &lt;li&gt; There is no such thing as a &lt;em&gt;final&lt;/em&gt; object. An object reference     marked &lt;em&gt;final&lt;/em&gt; does not mean the object itself is immutable.&lt;/li&gt;  &lt;li&gt; The transient modifier applies only to instance variables.&lt;/li&gt;  &lt;li&gt; The volatile modifier applies only to instance variables.&lt;/li&gt;  &lt;li&gt;Ranges of Numeric Primitives     &lt;ul&gt;      &lt;li&gt;&lt;em&gt;byte&lt;/em&gt; - has 8 bit. It range from -2&lt;sup&gt;7&lt;/sup&gt;to 2&lt;sup&gt;7&lt;/sup&gt;-1&lt;/li&gt;      &lt;li&gt;&lt;em&gt;short&lt;/em&gt; - has 16 bit. It range from -2&lt;sup&gt;15&lt;/sup&gt;to 2&lt;sup&gt;15&lt;/sup&gt;-1&lt;/li&gt;      &lt;li&gt;&lt;em&gt;int&lt;/em&gt; - has 32 bit. It range from -2&lt;sup&gt;31&lt;/sup&gt;to 2&lt;sup&gt;31&lt;/sup&gt;-1&lt;/li&gt;      &lt;li&gt;&lt;em&gt;long&lt;/em&gt; - has 64 bit. It range from -2&lt;sup&gt;63&lt;/sup&gt;to 2&lt;sup&gt;63&lt;/sup&gt;-1&lt;/li&gt;      &lt;li&gt;&lt;em&gt;float&lt;/em&gt; - has 32 bit. It range n/a&lt;/li&gt;      &lt;li&gt;&lt;em&gt;double&lt;/em&gt; - has 64 bit. It range n/a&lt;/li&gt;    &lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Array Declarations&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; Arrays can hold primitives or objects, but the array itself is always an     object.&lt;/li&gt;  &lt;li&gt; When you declare an array, the brackets can be to the left or right of     the variable name.&lt;/li&gt;  &lt;li&gt; It is never legal to include the size of an array in the declaration.&lt;/li&gt;  &lt;li&gt; An array of objects can hold any object that passes the IS-A (or instanceof)     test for the declared type of the array. For example, if Horse extends Animal,     then a Horse object: can go into an Animal array.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Static Variables and Methods&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; They are not tied to any particular instance of a class.&lt;/li&gt;  &lt;li&gt; No classes instances are needed in order to use &lt;em&gt;static&lt;/em&gt; members     of the class.&lt;/li&gt;  &lt;li&gt; There is only one copy of a &lt;em&gt;static&lt;/em&gt; variable / class and all instances     share it.&lt;/li&gt;  &lt;li&gt; &lt;em&gt;static&lt;/em&gt; methods do not have direct access to non-static members.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Enums &lt;sup&gt;&lt;font size="-1"&gt;*NEW&lt;/font&gt;&lt;/sup&gt;&lt;/h2&gt;&lt;ul&gt;  &lt;li&gt; An enum specifies a list of constant values that can be assigned to a particular     type. &lt;/li&gt;  &lt;li&gt; An enum is NOT a String or an int; an enum constant's type is the enum     type. For example, WINTER, SPRING, SUMMER, and FALL are of the enum type Season.&lt;/li&gt;  &lt;li&gt;Think of an enum as a kind of class, that looks something (but not exactly)     like this:&lt;br&gt;    &lt;code&gt;// conceptual example of how you can think&lt;br&gt;    // about enums&lt;br&gt;    &lt;br&gt;    class CoffeeSize {&lt;br&gt;    &amp;nbsp;&amp;nbsp;public static final CoffeeSize BIG =&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new CoffeeSize("BIG",     0);&lt;br&gt;    &amp;nbsp;&amp;nbsp;public static final CoffeeSize HUGE =&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new CoffeeSize("HUGE",     1);&lt;br&gt;    &amp;nbsp;&amp;nbsp;public static final CoffeeSize OVERWHELMING =&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new CoffeeSize("OVERWHELMING",     2);&lt;br&gt;    &lt;br&gt;    &amp;nbsp;&amp;nbsp;public CoffeeSize(String enumName, int index) {&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // stuff here&lt;br&gt;    &amp;nbsp;&amp;nbsp;}&lt;br&gt;    &amp;nbsp;&amp;nbsp;public static void main(String[] args) {&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(CoffeeSize.BIG);&lt;br&gt;    &amp;nbsp;&amp;nbsp;}&lt;br&gt;    }&lt;/code&gt; &lt;/li&gt;  &lt;li&gt; An enum can be declared outside or inside a class, but NOT in a method.&lt;/li&gt;  &lt;li&gt; An enum declared outside a class must NOT be marked &lt;em&gt;static&lt;/em&gt;, &lt;em&gt;final&lt;/em&gt;,     &lt;em&gt;abstract&lt;/em&gt;, &lt;em&gt;protected&lt;/em&gt;, or &lt;em&gt;private&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt; Enums can contain constructors, methods, variables, and constant class     bodies.&lt;/li&gt;  &lt;li&gt; enum constants can send arguments to the enum constructor, using the syntax     BIG(8), where the int literal 8 is passed to the enum constructor.&lt;/li&gt;  &lt;li&gt; enum constructors can have arguments, and can be overloaded:&lt;br&gt;    &lt;code&gt; enum CoffeeSize {&lt;br&gt;    &amp;nbsp;&amp;nbsp;BIG(8),&lt;br&gt;    &amp;nbsp;&amp;nbsp;HUGE(10),&lt;br&gt;    &amp;nbsp;&amp;nbsp;VERWHELMING(16) { &lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public String getLidCode() { // override the method&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "A";&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;    &amp;nbsp;&amp;nbsp;}; // the semicolon is REQUIRED when you have a body&lt;br&gt;    &lt;br&gt;    &amp;nbsp;&amp;nbsp;CoffeeSize(int ounces) {&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.ounces = ounces;&lt;br&gt;    &amp;nbsp;&amp;nbsp;}&lt;br&gt;    &lt;br&gt;    &amp;nbsp;&amp;nbsp;private int ounces;&lt;br&gt;    &lt;br&gt;    &amp;nbsp;&amp;nbsp;public int getOunces() {&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return ounces;&lt;br&gt;    &amp;nbsp;&amp;nbsp;}&lt;br&gt;    &amp;nbsp;&amp;nbsp;public String getLidCode() {&lt;br&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return "B"; &lt;br&gt;    &amp;nbsp;&amp;nbsp;}&lt;br&gt;    }&lt;br&gt;    &lt;/code&gt;&lt;/li&gt;  &lt;li&gt; enum constructors can NEVER be invoked directly in code. They are always     called automatically when an enum is initialized.&lt;/li&gt;  &lt;li&gt; The semicolon at the end of an enum declaration is optional. These are     legal:&lt;/li&gt;  &lt;ul&gt;    &lt;li&gt;enum Foo { ONE, TWO, THREE}&lt;/li&gt;    &lt;li&gt;enum Foo { ONE, TWO, THREE}&lt;/li&gt;  &lt;/ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6223315412069227645-5773697311825514905?l=java5inaction.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java5inaction.blogspot.com/feeds/5773697311825514905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6223315412069227645&amp;postID=5773697311825514905' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/5773697311825514905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6223315412069227645/posts/default/5773697311825514905'/><link rel='alternate' type='text/html' href='http://java5inaction.blogspot.com/2006/11/scjp-sun-certified-programmer-for-java.html' title='SCJP Sun Certified Programmer for Java 5 Study Guide(Chapter 1)'/><author><name>Dmitry</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
