1 / 40

Objectives for the SCPJ2 Exam

Objectives for the SCPJ2 Exam. Language Fundamentals Operators and Assignments Declarations and Access Control Flow Control and Exception Handling Garbage Collection. Objectives for the SCPJ2 Exam. Overloading Overriding Runtime Type and Object Orientation Threads

tarak
Download Presentation

Objectives for the SCPJ2 Exam

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objectives for the SCPJ2 Exam • Language Fundamentals • Operators and Assignments • Declarations and Access Control • Flow Control and Exception Handling • Garbage Collection

  2. Objectives for the SCPJ2 Exam • Overloading Overriding Runtime Type and Object Orientation • Threads • The java.awt package– Layout • The java .lang package • The java.util package

  3. Language Fundamentals 1 • Identify correctly constructed source files, package declarations, import statement, class declarations (of all forms including inner classes), interface declarations and implementations, method declarations, variable declarations and identifiers.

  4. Identifiers • Identifiers: Sequence of letters (Unicode), numbers, underscore (“_”) and Dollar Sign (“$”). • First Character must be a letter, $ or _. • Example of legal identifiers: • Number, Number, sum_$, $$_100, _mail, • Example of illigal identifiers: • 48chevy, all/clear, get-lost-fred

  5. Language Fundamentals 2 • State the correspondence between index values in the argument array passed to a main method and command line arguments. public static void main(String[] args) { int firsst = Integer.parseInt(args[0]); Char op = (char)agrs[1]; Int second = Integer.parseInt(args[2]); } > java Cal 1 + 2 • 3

  6. Language Fundamentals 3 • Identify all Java programming language keywords and correctly constructed identifiers. • Identifiers: Sequence of letters (Unicode), numbers, underscore (“_”) and Dollar Sign (“$”). • First Character must be a letter, $ or _. • Example of legal identifiers: • Number, Number, sum_$, $$_100, _mail, • Example of illigal identifiers: • 48chevy, all/clear, get-lost-fred

  7. Language Fundamentals 4 • State the effect of using a variable or array element of any kind when no explicit assignment has been made to it.

  8. Language Fundamentals 5 • State the range of all primitive data types and declare literal values for String and all primitive types using all permitted formats, bases, and representations.

  9. Language Fundamentals 6 • Write code to implement listener classes and methods, and in listener methods, extract information from the event to determine the affected component, mouse position, nature, and time of the event. State the event classname for any specified event listener interface in the java.awt.event package.

  10. Operators and Assignments 1 • Determine the result of applying any operator, including assignment operators and instanceof, to operands of any type, class, scope, or accessibility, or any combination of these.

  11. The instanceof Operator <reference> instanceof <destination type> • The instanceof operator effectively determines whether the object denoted by the reference on the left-hand side is an instance of the class (or of a subclass) that is specified on the right-hand side, or if it is an instance of a class (or of a subclass) that implements the interface specified on the right-hand side. • The instanceof operator returns the value true if the left-hand operand can be cast to the right-hand operand.

  12. instanceof class A {..} class A1 extends A {..} class B {..) class B1 extends B {..} class M { A a = new A(); A1 a1 = new A1(); B b = new B(); a instanceof A == true; a1 instanceof A == true; a instanceof B == false; }

  13. Operators and Assignments 2 • Determine the result of applying the boolean equals(Object) method to objects of any combination of the classes java.lang.String, java.lang.Boolean, and java.lang.Object. • Objects have the equals() method which can be used to compare objects.

  14. equals() String s1 = “Hello”; String s2 = new String(s1); s1.equals(s2)  true s1 == s2  false S1 ---- . Hello Hello S2 ---

  15. Operators and Assignments 3 • In an expression involving the operators &, |, &&, ||, and variables of known values state which operands are evaluated and the value of the expression.

  16. Operators and Assignments 4 • Determine the effect upon objects and primitive values of passing variables into methods and performing assignments or other modifying operations in that method. Parameters are passed by value. incl (int i) { i++; } i = 3; incl(i); System.out.println(“”+ i);

  17. Declarations and Access Control • Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for initialization.

  18. Declarations and Access Control • Declare classes, inner classes, methods, instance variables, static variables, and automatic (method local) variables making appropriate use of all permitted modifiers. State the significance of each of these modifiers both singly and in combination, and state the effect of package relationships on declared items qualified by these modifiers.

  19. Declarations and Access Control • For a given class determine if a default constructor will be created and if so state the prototype of the constructor. public class Point{ int x, int y; } default constructor: public Point() { super();}

  20. Declarations and Access Control • State the legal return types for any method given the declarations of all related methods in this or parent classes.

  21. Flow Control and Exception Handling 1 • Write code using if and switch statements and identify legal argument types for these statements.

  22. Flow Control and Exception Handling 1 • Write cod using all forms of loops including labeled and unlabeled use of break and continue and state the values taken by loop control variables during and after loop execution.

  23. The break/Continue Statement break/continue Identifieropt; • A break/continue statement transfers control out of an enclosing statement. • A break/continue statement with no label attempts to transfer control to the innermost enclosing switch, while, do, or for statement. • A break/continue statement with label Identifier attempts to transfer control to the enclosing labeled statement that has the same Identifier as its label.

  24. Flow Control and Exception Handling 2 • Write code that makes proper use of exceptions and exception handling clauses (try, catch, finally) and declares methods and overriding methods that throw exceptions.

  25. Garbage Collection • State the behavior that is guaranteed by the garbage collection system and write code that explicitly makes objects eligible for collection.

  26. Garbage Collection • Garbage collection is a mechanism for reclaiming memory from objects that are no longer in use, and making it available for new objects. • Objects that are created and accessed by local references in a method are eligible for garbage collection when the method terminates unless an object reference is returned or thrown as an exception.

  27. Garbage Collection • Object finalization provides a last resort to an object for undertaking any action before its storage is reclaimed. • The automatic garbage collector calls the finalize method in an object which is eligible for garbage collection before actually destroying the object. • The finalize method is an instance method defined in the class Object. • protected finalize() throws Throwable {

  28. Invoking Garbage Collection • The System.gc() method can be used to force garbage collection, and the System.runFinalization() method can be used to run the finalizers for objects eligible for garbage collection.

  29. Overloading Overriding Runtime Type and Object Orientation 1 • State the benefits of encapsulation in object oriented design and write code that implements tightly encapsulated classes and the relationships “is a” and “has a”.

  30. Overloading Overriding Runtime Type and Object Orientation 2 • Write code to invoke overridden or overloaded methods and parental or overloaded constructors; and describe the effect of invoking these methods.

  31. Overloading Overriding Runtime Type and Object Orientation 3 • Write code to construct instances of any concrete class including normal top level classes, inner classes, static inner classes, and anonymous inner classes.

  32. Overloading and Overriding • Overloading : Reusing the same method name with different arguments and perhaps a different return type. • Overriding: Using the same method name with identical arguments and return type.

  33. Overloading and Overriding • Overloaded methods supplement each other; an overriding method replaces the method it overrides. • Overloaded methods can exist in the same class. Each method in a parent class can be overridden at most once in any one subclass. • Overloaded methods must have different argument lists; overriding methods must have argument lists of identical type and order. • The return type of an overloaded method may be chosen freely; the return type of an overriding method must be identical to that of the method it overrides.

  34. Threads 1 • Write code to define, instantiate, and start new threads using both java.lang.Thread and java.lang.Runnable.

  35. Threads 2 • Recognize conditions that might prevent a thread from executing.

  36. Threads 3 • Write code using synchronized, wait, notify, and notifyall to protect against concurrent access problems and to communicate between threads. Define the interaction between threads and between threads and object locks when executing synchronized wait notify or notifyAll.

  37. The java.awt.package - Layout • Write code using component, container, and layout manager classes of the java.awt package to present a GUI with specified appearance and resize behavior, and distinguish the responsibilities of layout managers from those of containers.

  38. The java.lang package 1 • Write code using the following methods of the java.lang.Math class: abs, ceil, floor, max, min, random, round, sin, cos, tan, sqrt • int abs(int i), long abs(long l), float abs(float f), double abs(double d). • double ceil(double d): returns as a double the smallest integer that is not less than d. • double floor(double d): returns as a double the largest integer that is not greater than d. • double random(): returns a random number between 0.0 and 1.0

  39. The java.lang package 2 • Describe the significance of the immutability of String objects. • Strings are immutable objects, i.e. their contents cannot be changed in any way. String manipulation operations in the String class return new String objects as the result of the operation. The indexing of characters used by string operation is important. • StringBuffer implements a mutable sequence of characters.

  40. The java.util package • Make appropriate selection of collection classes/interface to suit specified behavior requirements.

More Related