SCJP - Mock Exam - 3
SCJP - Mock Exam - 3
SCJP - Mock Exam - 3
Exam No 3
Last Updated 16 September 2002
60 Questions
This is my mock Exam No 3 based on the Objectives for the Sun Java
Programmers for the Sun Java Programmers Exam. It was created by Marcus
Green and may be freely distributed so long as it is unmodified. Please email
me if you have any corrections or comments.
As of 5 Oct 2000 the question format has changed very slightly. You will now
get more questions that include snippets of code. My other two mock exams
contain more code based questions than this one. Each question will also tell
you how many of the options you need to pick. You can read more about these
revisions at http://www.jchq.net/faq/ExamUpdate.htm. You should assume that
the real thing will be harder though many people have told me that they get
similar marks in the real thing to my exams
This is a long document (around 35 pages), if you cannot see the answers then
you have not got the entire document, try reloading it until you can see the
answer to the final see the answer to the final question and the words "End of
document". The answers contain references to approximately which objective
the question relates to. If you have a query about any of these questions,
please, please include the full answer with the question. You can jump back
from an answer to the question by pressing the back button on your web
browser.
Questions
Question 1)
1) float f=1/3;
2) int i=1/3;
3) float f=1.01;
4) double d=999d;
Answer to Question 1)
Question 2)
1) NULL
2) new
3) instanceOf
4) wend
Answer to Question 2)
Question 3)
Which of the following are valid statements?
1) System.out.println(1+1);
2) int i=2+'2';
3) String s="on"+'one';
4) byte b=255;
Answer to Question 3)
Question 4)
Answer to Question 4)
Question 5)
Answer to Question 5)
Question 6).
Which of the following statements are true?
Answer to Question 6)
Question 7)
Answer to Question 7)
Question 8)
Answer to Question 8)
Question 9)
1) run
2) start
3) yield
4) stop
Answer to Question 9)
Question 10)
Question 11)
What will happen when you attempt to compile and run the following code
class Base{
public void Base(){
System.out.println("Base");
}
}
public class In extends Base{
public static void main(String argv[]){
In i=new In();
}
}
Question 12)
You have a public class called myclass with the main method defined as follows
If you attempt to compile the class and run the program as follows
Question 13)
Question 14)
Question 15)
Question 16)
What will happen when you attempt to compile and run the following class?
class Base{
Base(int i){
System.out.println("Base");
}
}
Question 17)
1) static methods do not have access to the implicit variable called this
2) A static method may be called without creating an instance of its class
3) A static method may not be overriden to be non-static
4) A static method may not be overloaded
Question 18)
char c='1';
System.out.println(c>>1);
2)
Integer i=Integer("1");
System.out.println(i>>1);
3)
int i=1;
System.out.println(i<<<1);
4)
int i=1;
System.out.println(i<<1);
Question 19)
Question 20)
Question 21)
Question 22)
Question 23)
Question 24)
Question 25)
1) The elements in a Java array can only be of primitive types, not objects
2) Arrays elements are initialized to default values wherever they are created
using the keword new
3) An array may be dynamically resized using the setSize method
4) You can find out the size of an array using the size method
Question 27)
What will happen when you attempt to compile and run it?
Question 28)
You are given a class hierarchy with an instance of the class Dog. The class
Dog is a child of mammal and the class Mammal is a child of the class
Vertebrate. The class Vertebrate has a method called move which prints out the
string "move". The class mammal overrides this method and prints out the
string "walks". The class Dog overrides this method and prints out the string
"walks on paws". Given an instance of the class Dog,. how can you access the
ancestor method move in Vertebrate so it prints out the string "move";
1) d.super().super().move();
2) d.parent().parent().move();
3) d.move();
4) none of the above;
Question 29)
1) A class with the same name replaces the functionality of a class defined
earlier in the hierarchy
2) A method with the same name completely replaces the functionality of a
method earlier in the hierarchy
3) A method with the same name but different parameters gives multiple uses
for the same method name
4) A class is prevented from accessing methods in its immediate ancestor
Question 31)
Question 32)
Which of the following statements are true about a variable created with the
static modifier?
1) Java uses a system called UTF for I/O to support international character sets
2) The RandomAccessFile is the most suitable class for supporting
international character sets
3) An instance of FileInputStream may not be chained to an instance of
FileOutputStream
4) File I/O activities requires use of Exception handling
Question 34)
What will happen when you attempt to compile and run the following code?
import java.io.*;
class ExBase{
abstract public void martley(){
}
Question 35)
What will happen when you attempt to compile and run the following code
Question 36)
Assuming any exception handling has been set up, which of the following will
create an instance of the RandomAccessFile class
Question 37)
Which of the following would be legal to place after the comment //Here ?
1) public int amethod(int z){}
2) public int amethod(int i,int j){return 99;}
3) protected void amethod(long l){ }
4) private void anothermethod(){}
Question 38)
1) The code will not compile because the classes are nested to more than one
level
2) The code will not compile because class two is marked as private
3) The code will compile and output the string two at runtime
4) The code will compile without error
Question 40)
class Base{
static int oak=99;
}
Which of the following if placed after the comment //Here, will compile and
modify the value of the variable oak?
1) super.oak=1;
2) oak=33;
3) Base.oak=22;
4) oak=50.1;
Question 41)
You are creating an application that has a form with a text entry field used to
enter a persons age. Which of the following is appropriate for capturing this
information.
1) Use the Text field of a TextField and parse the result using Integer
2) Use the getInteger method of the TextField
3) Use the getText method of a TextBox and parse the result using the getInt
method of Integer class
4) Use the getText method of a TextField and use the parseInt method of the
Integer class
Question 42)
1) i=10;
2) i.setValue(10);
3) i.parseInt(10);
4) none of the above
Question 43)
Question 44)
to a class which extends Thread, which of the following will cause it to give up
cycles to allow another thread to execute.
1) t.yield();
2) Thread.yield();
3) yield(100); //Or some other suitable amount in milliseconds
4) yield(t);
Question 45)
What will happen when you attempt to compile and run the following code?
Question 46)
Question 47)
What will happen when you attempt to compile and run the following code?
class Base{
Base(){
System.out.println("Base");
}
}
Checket(){
System.out.println("Checket");
}
}
Question 48)
Which of the following statements are true?
Question 49)
1) The automatic garbage collection of the JVM prevents programs from ever
running out of memory
2) A program can suggest that garbage collection be performed but not force it
3) Garbage collection is platform independent
4) An object becomes eligible for garbage collection when all references
denoting it are set to null.
Question 50)
}
What will happen if you attempt to compile and run this code with the command
line
java Sytch Jones Diggle
1) Compilation and output of Ms Diggle Please pay $2000
2) Compile time error
3) Compilation and output of Ms Jones Please pay $2000
4) Compilation but runtime error
Question 51)
What will happen when you attempt to compile and run the following code
class Base{
protected int i = 99;
}
public class Ab{
private int i=1;
public static void main(String argv[]){
Ab a = new Ab();
a.hallow();
}
Question 52)
You have been asked to create a scheduling system for a hotel and catering
organsiation.
You have been given the following information and asked to create a set of
classes to represent it.
Head Chefs
Chefs
Apprentice Chefs
The system needs to store an employeeid, salary and the holiday entitlement
How would you best represent this information in Javae been given the
following information and asked to create a set of classes to represent it.
1) Create classes for Head Chef, Chef, Apprentice Chef and store the other
values in fields
2) Create an employee class and derive sub classes for Head Chef, Chef,
Apprentice Chef and store the other values in fields.
3) Create and employee class with fields for Job title and fields for the other
values.
4) Create classes for all of the items mentioned and create a container class to
represent employees
Question 53)
You need to read in the lines of a large text file containing tens of megabytes of
data. Which of the following would be most suitable for reading in such a file
1) new FileInputStream("file.name")
2) new InputStreamReader(new FileInputStream("file.name"))
3) new BufferedReader(new InputStreamReader(new
FileInputStream("file.name")));
4) new RandomAccessFile raf=new RandomAccessFile("myfile.txt","+rw");
Question 54)
What will happen when you attempt to compile and run the following code?
Question 55)
What will happen when you attempt to compile and run the following code?
Question 56)
Which of the following lines if placed after the comment //Here will print out 0.
1) System.out.println(i++);
2) System.out.println(i+'0');
3) System.out.println(i);
4) System.out.println(i--);
class Base {}
What code placed after the comment //Here will result in calling the getFields
method resulting in the output of the string "Agg"?
1) System.out.println(a.getFields());
2) System.out.println(a.name);
3) System.out.println((Base) a.getFields());
4) System.out.println( ((Agg) a).getFields());
Question 58)
What will happen when you attempt to compile and run the following code.
Question 59)
Question 60)
import java.io.*;
Answers
Answer to Question 1)
Objective 4.5)
1) float f=1/3;
2) int i=1/3;
4) double d=999d;
The fact that option 3 does not compile may be a surprise. The problem is
because the default type for a number with a decimal component is a double
and not a float. The additional trailing d in the option with 999 doesn't help, but it
doesn't harm.
http://www.jchq.net/tutorial/04_05Tut.htm
Answer to Question 2)
Objective 4.3)
2) new
The option NULL (note the upper case letter) is definitely not a keyword. There
is some discussion as to i. There is some discussion as to if null is a keyword
but for the purpose of the exam you should probably assume it is a keyword.
The option instanceOf is a bit of a misleading option that would probably not
occur on the exam. The real keyword is instanceof (note that the of has no
capital letter O). I had the incorrect version in an earlier version of this tutorial as
it looks more likely to my eyes. The instanceof keyword looks like a method, but
it is actually an operator.
The option wend is probably valid in some other language to indicate the end of
a while loop, but Java has no such keyword.
http://www.jchq.net/tutorial/04_03Tut.htm
Answer to Question 3)
Objective 4.5)
1) System.out.println(1+1);
2) int i=2+'2';
Option 3 is not valid because single quotes are used to indicate a character
constant and not a string. Several people have emailed me to say that option 3
will compile. When they eventually compiled the exact code they have agreed,
it will not compile. Let me re-state that
String s="on"+'one';
Option 4 will not compile because 255 is out of the range of a byte
http://www.jchq.net/tutorial/04_05Tut.htm
Answer to Question 4)
Objective 7.1)
Threading and garbage collection are two of the few areas that are platform
dependent. This is one of the
reasons why Java is not suitable for realtime programming. It is not a good idea
use it to control your
plane or nuclear power station. Once an instance of the Integer class has a
value it cannot be changed.
http://www.jchq.net/tutorial/07_01Tut.htm
Answer to Question 5)
Objective 10.1)
(Not on the official sub objectives but this topic does come up on the exam)
2) The RandomAccessFile class allows you to move directly to any point a file.
4) The characteristics of an instance of the File class such as the directory
separator, depend on the current underlying operating system
The File class can be considered to represent information about a file rather
than a real file object. You can create a file in the underlying operating system
by passing an instance of a file to a stream such as FileOutputStream. The file
will be created when you call the close method of the stream.
http://www.jchq.net/tutorial/10_01Tut.htm
Answer to Question 6)
Objective 5.1)
The instanceof operator can only be used to make a static comparison with a
class type. Java1.1 added the isInstance method to the class Class to allow you
to dynamically determine a class type. The exam does not test you on
isInstance.
http://www.jchq.net/tutorial/05_01Tut.htm
Answer to Question 7)
Objective 4.1)
If you try to create a constructor for an Interface the compiler will give you an
error message something like
4) Interfaces are the Java approach to addressing the single inheritance model,
but require implementing classes to create the functionality of the Interfaces.
Answer to Question 8)
Objective 9.1)
None of these are valid statements. The Math class is final and cannot be
extended. The max method takes two parameters, round only takes one
parameter and there is no mod parameter. You may get questions in the exam
that have no apparently correct answer. If you are absolutely sure this is the
case, do not check any of the options.
http://www.jchq.net/tutorial/09_01Tut.htm
Answer to Question 9)
Objective 7.1)
1) The Runnable interface has only one method run that needs to be created in
any class that implements it. The start method is used to actually call and start
the run method executing.
http://www.jchq.net/tutorial/07_01Tut.htm
Objective 4.5)
The char type is the only unsigned type in Java and thus cannot represent a
negative number.
http://www.jchq.net/tutorial/04_05Tut.htm
Answer to Question 11)
Objective 1.2)
Because the method in Base called Base has a return type it is not a
constructor and there for does not get called on creation of an instance of its
child class In
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 4.2)
http://www.jchq.net/tutorial/04_02Tut.htm
Objective 1.2)
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 1.2)
Option 1 is not valid because it has braces and the native modifier means that
the method can have no body. This is because the body must be implemented
in some other language (often C/C++). Option 3 is not valid because private
and protected contradict themselves.
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 6.2)
http://www.jchq.net/tutorial/06_02Tut.htm
Answer to Question 16)
Objective 1.3)
An error occurs when the class Severn attempts to call the zero parameter
constructor in the class Base Because the Base class has an integer
constructor Java does not provide the "behind the scenes" zero parameter
constructor.
http://www.jchq.net/tutorial/01_03Tut.htm
Objective 1.2)
1) static methods do not have access to the implicit variable called this
2) A static method may be called without creating an instance of its class
3) a static may not be overriden to be non-static
The implicit variable this refers to the current instance of a class and thus and
by its nature a static method cannot have access to it.
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 5.1)
1)
char c='1';
System.out.println(c>>1);
4)
int i=1;
System.out.println(i<<1);
Be aware that Integer (not the upper case I) is a wrapper class and thus cannot
be treated like a primitive. The fact that option 1 will compile may be a surprise,
but although the char type is normally used to store character types, it is
actually an unsigned integer type. The reason option 3 does not compile is that
Java has a >>> operator but not a <<< operator. ;>> operator but not a <<<
operator.
http://www.jchq.net/tutorial/05_01Tut.htm
Objective 4.6)
A component may have multiple event listeners attached. Thus a field may
need to respond to both the mouse and the keyboard, requiring multiple event
handlers. The ActionListener has not matching Adapter class because it has
only one method, the idea of the Adapter classes is to eliminate the need to
create blank methods.
http://www.jchq.net/tutorial/04_06Tut.htm
3) transient
4) volatile
Option 1, sizeof is designed to catch out the C/C++ programmers. Java does
not have a sizeof keyword as the size of primitives should be consistent on all
Java implementations. Although a program needs a main method with the
standard signature to start up it is not a keyword. The real keywords are less
commonly used and therefore might not be so familiar to you.
http://www.jchq.net/tutorial/04_03Tut.htm
Objective 1.3)
http://www.jchq.net/tutorial/05_01Tut.htm
Objective 4.1)
1) All of the variables in an interface are implicitly static
2) All of the variables in an interface are implicitly final
3) All of the methods in an interface are implictly abstract
All the variables in an interface are implicitly static and final. Any methods in an
interface have no body, so may not access any type of variable
http://www.jchq.net/tutorial/04_01Tut.htm
Objective 4.5)
In Java Strings are implemented as a class within the Java.lang package with
the special distinction that the + operator is overloaded. If you thought that the
String class is implemented as a char array, you may have a head full of C/++
that needs emptying. There is not "wrapper class" for String as wrappers are
only for primitive types.
If you are surprised that option 4 is not a correct answer it is because length is a
method for the String class, but a property for and array and it is easy to get the
two confused.
http://www.jchq.net/tutorial/05_01Tut.htm
Objective 6.1)
http://www.jchq.net/tutorial/06_01Tut.htm
Answer to Question 25)
Objective 5.1)
Although you might not know the exact result of the operation -1 >>> 2 a
knowledge of the way the bits will be shifted will tell you that the result is not
plus 1. (The result is more like 1073741823 ) There is no such Java operator as
the unsigned left shift. Although it is normally used for storing characters rather
than numbers the char Java primitive is actually an unsigned integer type.
http://www.jchq.net/tutorial/05_01Tut.htm
http://www.jchq.net/tutorial/04_05Tut.htm
Objective 4.4)
2) Arrays elements are initialized to default values wherever they are created
using the keyword new.
You can find the size of an array using the length field. The method length is
used to return the number of characters in a String. An array can contain
elements of any type but they must all be of the same type. The size of an array
is fixed at creation. If you want to change its size you can of course create a
new array and assign the old one to it. A more flexible approach can be to use a
collection class such as Vector.
http://www.jchq.net/tutorial/04_04Tut.htm
Answer to Question 27)
Objective 5.3)
This code is an example of a short circuited operator. Because the first operand
of the || (or) operator returns true Java sees no reason to evaluate the second.
Whatever the value of the second the overall result will always be true. Thus the
method called place is never called.
http://www.jchq.net/tutorial/05_03Tut.htm
Objective 6.2)
You may access methods of a direct parent class through the use of super but
classes further up the hierarchy are not visible.
http://www.jchq.net/tutorial/06_02Tut.htm
Objective 6.1)
Objective 1.2)
The % is the modulo operator and returns the remainder after a division. Thus
10 % 3=1
The $ symbol may be used as the first character of a variable, but I would
suggest that it is generally not a good idea. The # symbol cannot be used
anywhere in the name of a variable. Knowing if a variable can start with the # or
$ characters may seem like arbitrary and non essential knowlege but questions
like this do come up on the exam.
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 8.1)
http://www.jchq.net/tutorial/08_01Tut.htm
Objective 1.2)
3) Only one instance of a static variable will exist for any amount of class
instances
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 11.1)
1) Java uses a system called UTF for I/O to support international character sets
3) An instance of FileInputStream may not be chained to an instance of
FileOutputStream
4) File I/O activities requires use of Exception handling
Internally Java uses Unicode which are 16 bit characters. For I/O Java uses
UTF which may be more thatn 16 bits per chamore thatn 16 bits per character.
Generally InputStreams can only be chained to other InputStreams and
OutputStreams can only be chained to other OutputStreams. The piped
streams are an exception to this.
http://www.jchq.net/tutorial/11_01Tut.htm
Objective 1.2)
It wil produce an error like "Abstract and native method can't have a body. This
is typical of the more misleading question where you might think it is asking you
about the circumstances under which the finally clause runs, but actually it is
about something else.
http://www.jchq.net/tutorial/07_02Tut.htm
Answer to Question 35)
Objective 7.1)
http://www.jchq.net/tutorial/07_01Tut.htm
Objective 11.1)
http://www.jchq.net/tutorial/11_01Tut.htm
Objective 6.2)
Option 1 will not compile on two counts. One is the obvious one that it claims to
return an integer. The other is that it is effectivly an attempt to redefine a
method within the same class. The change of name of the parameter from i to z
has no effect and a method cannot be overriden within the same class.
http://www.jchq.net/tutorial/06_02Tut.htm
1) Code must be written to cause a frame to close on selecting the system close
menu
2) The default layout for a Frame is the BorderLayout Manager
4) The GridBagLayout manager makes extensive use of the the
GridBagConstraints class.
You can change the layout manager for a Frame or any other container
whenever you like.
http://www.jchq.net/tutorial/08_01Tut.htm
Objective 1.2)
There are no restrictions on the level of nesting for inner/nested classes. Inner
classes may be marked private. The main method is not declared as public
static void main, and assuming that the commandline was java Droitwich it
would not be invoked anyway.
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 1.2)
1) super.oak=1;
2) oak=33;
3) Base.oak=22;
Because the variable oak is declared as static only one copy of it will exist. Thus
it can be changed either through the name of its class or through the name of
any instance of that class. Because it is created as an integer it canot be
assigned a fractional component without a cast.
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 4.6)
4) Use the getText method of a Textfield and use the parseInt method of the
Integer class
Integer.parseInt(txtInputValue.getText());
I'm not sure that a question on this actually will come up in the exam but it is a
very useful thing to know in the real world.
http://www.jchq.net/tutorial/04_06Tut.htm
Objective 4.6)
http://www.jchq.net/tutorial/04_06Tut.htm
Objective 6.2)
http://www.jchq.net/tutorial/06_02Tut.htm
Objective 7.1)
1) t.yield();
2) Thread.yield()
(Thanks Roseanne )
http://www.jchq.net/tutorial/07_01Tut.htm
JavaDoc for the Thread class
http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Thread.html
Objective 6.2)
The fact that the variable court is declared as private does not stop the
constructor from being able to initialise it.
http://www.jchq.net/tutorial/06_02Tut.htm
Objective 6.2)
3) To be overriden a method must have the same name, parameter and return
types
http://www.jchq.net/tutorial/06_02Tut.htm
Objective 6.2)
If you took out the call to super that causes this error the program would
compile and at runtime it would output Base and then Checket as constructors
are called from the oldest ancestor class downwards.
http://www.jchq.net/tutorial/06_02Tut.htm
Objective 1.2)
The JDK1.1 compiler will issue an error message "static methods cannot be
overriden" if you atempt to do thiuot; if you atempt to do this. There is no logic or
atempt to do this. There is no logic or reason why private methods should not
be overloaded or that static methods should not be declared private. Option 4 is
a jumbled up version of the limitations of exceptions for overriden methods
http://www.jchq.net/tutorial/01_02Tut.htm
Objective 3.1)
2) A program can suggest that garbage collection be performed but not force it
4) A reference becomes eligable for garbage collection when it is assigned to
null
If a program keeps creating new references without any being discarded it may
run out of memory. Unlike most aspects of Java garbage collection is platform
dependent.
http://www.jchq.net/tutorial/03_01Tut.htm
Answer to Question 50)
Objective 1.2)
The main method is static and cannot access the non static variable x
http://www.jchq.net/tutorial/01_02Tut.htm
Abstract and native methods can't have a body: void hallow() abstract void
hallow()
http://www.jchq.net/tutorial/01_02Tut.htm
3) Create and employee class with fields for Job title and fields for the other
values.
These questions can appear tricky as the whole business of designing class
structures is more art than science. It is asking you to decide if an item of data is
best represented by the "Is a" or "Has a" relationship. Thus in this case any of
the job titles mentioned will always refer to something that "Is a" employee.
However the employee "has a" job title that might change.
One of the important points is to ask yourself when creating a class "Could this
change into another class at some point in the future". Thus in this example an
apprentice chef would hope one day to turn into a chef and if she is very good
will one day be head chef. Few other mock exams seem to have this type of
questions but they di come up in the real exam.
http://www.jchq.net/tutorial/06_01Tut.htm
Objective 11.1)
The key to this question is that it asks about tens of megabytes of data, implying
that performance is an issue. A Buffered Reader will optimise the performance
of accessing a file. Although the objectives do not specifically mention it
questions on I/O do come up on the exam.
http://www.jchq.net/tutorial/11_01Tut.htm
Objective 5.4)
4) Output of 0
The method fermin only receives a copy of the variable i and any modifications
to it are not reflected in the version in the calling method. The post increment
operator ++ effectivly modifes the value of i after the initial value has been
assiged to the left hand side of the equals operator. This can be a very tricky
conept to understand
http://www.jchq.net/tutorial/05_04Tut.htm
http://www.jchq.net/tutorial/02_02Tut.htm
Objective 5.1)
1) System.out.println(i++);
3) System.out.println(i);
4) System.out.println(i==);
The options for this question might look suspiciously easy if you are not aware
of the effects of the post-increment operators. The ++ and == operations for
examples 1 and 4 only come into effect after the output operations, ie after
whatever else is done to them on that line of code. Option 2 should be fairly
obvious as you should know that the single quote characters indicate a char
value, ie storing the character rather than the numberical value for 0.
http://www.jchq.net/tutorial/05_01Tut.htm
Objective 6.2)
http://www.jchq.net/tutorial/06_02Tut.htm
Objective 4.4)
A variable defined at class level will always be given a default value and the
default value for the primitive type boolean is false
http://www.jchq.net/tutorial/04_04Tut.htm
Objective 4.6)
If you chose option 4, referring to the mythical getTime method you have made
a reasonable guess based on the normal conventions of Java. However the
conventions do not always hold true. If you chose option 3 perhaps you are not
as aware of the conventions as you should be.
http://www.jchq.net/tutorial/04_06Tut.htm
Answer to Question 60)
Objective 2.3
This question tests your knowledge of the principle that the finally clause will
almost always run.
http://www.jchq.net/tutorial/02_03Tut.htm
30)Objective 1.2)
48)Objective 1.2)
39)Objective 1.2)
40)Objective 1.2)
50)Objective 1.2)
51)Objective 1.2)
17)Objective 1.2)
32)Objective 1.2)
14)Objective 1.2)
11)Objective 1.2)
13)Objective 1.2)
34)Objective 1.2)
55)Objective 2.2)
60)Objective 3.4)
16)Objective 1.3)
21)Objective 1.3)
49)Objective 3.1)
26)Objective 4.4)
1)Objective 4.5)
3)Objective 4.5)
10)Objective 4.5)
22)Objective 4.1)
7) Objective 4.1)
12)Objective 4.2)
2) Objective 4.3)
23)Objective 4.5)
42)Objective 4.6)
41)Objective 4.6)
19)Objective 4.6)
20)Objective 4.3)
48)Objective 4.4)
59)Objective 4.6)
6) Objective 5.1)
25)Objective 5.1)
18)Objective 5.1)
27)Objective 5.3)
54)Objective 5.4)
56)Objective 5.1)
24)Objective 6.1)
29)Objective 6.1)
52)Objective 6.1)
45)Objective 6.2)
46)Objective 6.2)
47)Objective 6.2)
43)Objective 6.2)
37)Objective 6.2)
28)Objective 6.2)
15)Objective 6.2)
4)Objective 7.1)
9)Objective 7.1)
35)Objective 7.1)
44)Objective 7.1)
31)Objective 8.1)
38)Objective 8.1)
8)Objective 9.1)
5)Objective 10.1)
33)Objective 11.1)
36)Objective 11.1)
53)Objective 11.1)
End of document