Exam Number/Code : 1Z Exam Name: Name: Java Standard Edition 6. Demo. Version : Programmer Certified Professional Exam.

Similar documents
Testpassport.

SUN Certified Programmer for J2SE 5.0 Upgrade. Download Full Version :

Language Fundamentals

RZQ 12/19/2008 Page 1 of 11

Threads Chate Patanothai

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007

Java Threads. COMP 585 Noteset #2 1

Overview. Processes vs. Threads. Computation Abstractions. CMSC 433, Fall Michael Hicks 1

Animation Part 2: MoveableShape interface & Multithreading

Multithreaded Programming

Contents. 6-1 Copyright (c) N. Afshartous

Module 2- 类 接口以及枚举一 选择题 :

Introduction to Java Threads

Synchronization in Java

CS 556 Distributed Systems

Unit 5 - Exception Handling & Multithreaded

7. MULTITHREDED PROGRAMMING

COE318 Lecture Notes Week 10 (Nov 7, 2011)

Oracle 1Z0-851 Exam Questions & Answers

OCJP 6_v.2013_vishal. Number: 1Z0-851 Passing Score: 800 Time Limit: 120 min File Version: 2013.

ECE 461 Fall 2011, Final Exam

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

By: Abhishek Khare (SVIM - INDORE M.P)

Sun.RealExamQuestions Oracle.1Z0-851.v by.Carlos.239q

CMSC 132: Object-Oriented Programming II. Threads in Java

Oracle 1Z0-851 Exam Questions & Answers

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA

GlobalLogic Technical Question Paper

Oracle 1Z Java Standard Edition 5 Programmer Certified Professional.

Chair of Software Engineering. Java and C# in Depth. Prof. Dr. Bertrand Meyer. Exercise Session 8. Nadia Polikarpova

CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015

ECE 462 Midterm Exam 2. 10:30-11:20AM, October 19, 2007

Programming Language Concepts: Lecture 11

What is a thread anyway?

JAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling

Concurrent Programming using Threads

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

JAVA Programming Language Homework I - OO concept

Principles of Software Construction: Concurrency, Part 2

Class, Variable, Constructor, Object, Method Questions

CMPSCI 187: Programming With Data Structures. Lecture #20: Concurrency and a Case Study David Mix Barrington 24 October 2012

COMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions

Lecture 24: Java Threads,Java synchronized statement

Threads and Parallelism in Java

Fundamentals of Object Oriented Programming

Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci

THE UNIVERSITY OF WESTERN AUSTRALIA SAMPLE EXAM QUESTIONS 2007 WITH SOLUTIONS SCHOOL OF COMPUTER SCIENCE CITS3213 CONCURRENT PROGRAMMING (PART II)

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

Software Practice 1 - Multithreading

Practice Questions for Chapter 9

Multi-threading in Java. Jeff HUANG

Exercise Session Week 8

CH. 2 OBJECT-ORIENTED PROGRAMMING

Oracle 1Z Java SE 8 Programmer I. Download Full Version :

Oracle 1z Java Standard Edition 5 Programmer Certified Professional Upgrade Exam. Practice Test. Version:

CMSC 132: Object-Oriented Programming II

User Space Multithreading. Computer Science, University of Warwick

Exercise Session Week 8

Note: Each loop has 5 iterations in the ThreeLoopTest program.

Review what constitutes a thread Creating threads general Creating threads Java What happens if synchronization is not used? Assignment.

Multithreading. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

CSCD 330 Network Programming

ECE462Exam3. 08:10-09:20AM, November 20, 2009

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

INFO Ass 4. Exercise 1

Basics of. Multithreading in Java

Concurrency in Java Prof. Stephen A. Edwards

Java. Massimo Dong. November 27, Massimo Dong Java November 27, / 26

Self-test Java Programming

Multithreading using Java. Dr. Ferdin Joe John Joseph

System Programming. Practical Session 4: Threads and Concurrency / Safety

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

Part IV Other Systems: I Java Threads

An Introduction to Programming with Java Threads Andrew Whitaker University of Washington 9/13/2006. Thread Creation

Unit 4. Thread class & Runnable Interface. Inter Thread Communication

This Download is from

Oracle. Exam Questions 1Z Java Standard Edition 6 Programmer Certified Professional Exam. Version:Demo

ECE Fall 2017, Third Exam

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Advanced Concepts of Programming

CSCD 330 Network Programming

Vendor: Oracle. Exam Code: 1Z Exam Name: Java Certified Programmer. Version: Demo

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

CS180 Review. Recitation Week 15

Le L c e t c ur u e e 7 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Multithreading

UNIT IV MULTITHREADING AND GENERIC PROGRAMMING

MCS-378 Intraterm Exam 1 Serial #:

Multiple Inheritance. Computer object can be viewed as

Exam Name: SUN CERTIFIED PROGRAMMER FOR

Module - 4 Multi-Threaded Programming

Midterm Exam CS 251, Intermediate Programming March 12, 2014

Exam Name: Java Standard Edition 6 Programmer Certified Professional Exam

Handouts. 1 Handout for today! Recap. Homework #2 feedback. Last Time. What did you think? HW3a: ThreadBank. Today. Small assignment.

Selected Java Topics

Modern Programming Languages. Lecture Java Programming Language. An Introduction

SUN Sun Certified Associate for the Java Platform.

Transcription:

Exam Number/Code : 1Z0-851 Exam Name: Name: Java Standard Edition 6 Programmer Certified Professional Exam Version : Demo http://it-shiken.jp/

QUESTION 1 public class Threads2 implements Runnable { public void run() { System.out.println("run."); throw new RuntimeException("Problem"); public static void main(string[] args) { Thread t = new Thread(new Threads2()); t.start(); System.out.println("End of method."); Which two can be results? (Choose two.) A. java.lang.runtimeexception: Problem B. run. java.lang.runtimeexception: Problem C. End of method. java.lang.runtimeexception: Problem D. End of method. run. java.lang.runtimeexception: Problem E. run. java.lang.runtimeexception: Problem End of method. Answer: DE End of method. run. Exception in thread "Thread-0" java.lang.runtimeexception: Problem at Threads2.run(Threads2.java:5) at java.lang.thread.run(unknown Source) QUESTION 2 Which two statements are true? (Choose two.) A. It is possible for more than two threads to deadlock at once.

B. The JVM implementation guarantees that multiple threads cannot enter into a deadlocked state. C. Deadlocked threads release once their sleep() method's sleep duration has expired. D. Deadlocking can occur only when the wait(), notify(), and notifyall() methods are used incorrectly. E. It is possible for a single-threaded application to deadlock if synchronized blocks are used incorrectly. F. If a piece of code is capable of deadlocking, you cannot eliminate the possibility of deadlocking by inserting invocations of Thread.yield(). Answer: AF QUESTION 3 void waitforsignal() { Object obj = new Object(); synchronized (Thread.currentThread()) { obj.wait(); obj.notify(); Which statement is true? A. This code can throw an InterruptedException. B. This code can throw an IllegalMonitorStateException. C. This code can throw a TimeoutException after ten minutes. D. Reversing the order of obj.wait() and obj.notify() might cause this method to complete normally. E. A call to notify() or notifyall() from another thread might cause this method to complete normally. F. This code does NOT compile unless "obj.wait()" is replaced with "((Thread) obj).wait()". Answer: B Not quite sure about the answer, because first of all this code will not compile: Threads2.java:15: unreported exception java.lang.interruptedexception; must be caught or declared to be thrown obj.wait(); ^ 1 error

QUESTION 4 class PingPong2 { synchronized void hit(long n) { for(int i = 1; i < 3; i++) System.out.print(n + "-" + i + " "); public class Tester implements Runnable { static PingPong2 pp2 = new PingPong2(); public static void main(string[] args) { new Thread(new Tester()).start(); new Thread(new Tester()).start(); public void run() { pp2.hit(thread.currentthread().getid()); Which statement is true? A. The output could be 5-1 6-1 6-2 5-2 B. The output could be 6-1 6-2 5-1 5-2 C. The output could be 6-1 5-2 6-2 5-1 D. The output could be 6-1 6-2 5-1 7-1 Answer: B QUESTION 5 public class Threads4 { public static void main (String[] args) { new Threads4().go(); public void go() { Runnable r = new Runnable() { public void run() {

System.out.print("foo"); ; Thread t = new Thread(r); t.start(); t.start(); What is the result? A. Compilation fails. B. An exception is thrown at runtime. C. The code executes normally and prints "foo". D. The code executes normally, but nothing is printed. Answer: B Exception in thread "main" java.lang.illegalthreadstateexception at java.lang.thread.start(unknown Source) at Threads4.go(Threads4.java:14) at Threads4.main(Threads4.java:3) foo QUESTION 6 public abstract class Shape { private int x; private int y; public abstract void draw(); public void setanchor(int x, int y) { this.x = x; this.y = y; Which two classes use the Shape class correctly? (Choose two.) A. public class Circle implements Shape {

B. public abstract class Circle extends Shape { C. public class Circle extends Shape { public void draw(); D. public abstract class Circle implements Shape { public void draw(); E. public class Circle extends Shape { public void draw() {/* code here */ F. public abstract class Circle implements Shape { public void draw() {/* code here */ Answer: BE QUESTION 7 public class Barn { public static void main(string[] args) { new Barn().go("hi", 1); new Barn().go("hi", "world", 2); public void go(string... y, int x) { System.out.print(y[y.length - 1] + " "); What is the result? A. hi hi B. hi world

C. world world D. Compilation fails. E. An exception is thrown at runtime. Answer: D The method go(string[], int) in the type Barn is not applicable for the arguments (String, int) The variable argument type String of the method go must be the last parameter QUESTION 8 class Nav{ public enum Direction { NORTH, SOUTH, EAST, WEST public class Sprite{ // insert code here Which code, inserted at line 14, allows the Sprite class to compile? A. Direction d = NORTH; B. Nav.Direction d = NORTH; C. Direction d = Direction.NORTH; D. Nav.Direction d = Nav.Direction.NORTH; Answer: D QUESTION 9 Which statement is true about the classes and interfaces in the exhibit? 01. public interface A { 02. public void dosomething(string thing); 03. 01. public class AImpl implements A { 02. public void dosomething(string msg) {

03. 01. public class B { 02. public A doit(){ 03. //more code here 04. 05. public String execute(){ 06 //more code here 07 08. 01. public class C extends B { 02. public AImpl doit(){ 03. //more code here 04. 05. 06. public Object execute() { 07. //more code here 08. 09. A. Compilation will succeed for all classes and interfaces. B. Compilation of class C will fail because of an error in line 2. C. Compilation of class C will fail because of an error in line 6. D. Compilation of class AImpl will fail because of an error in line 2. Answer: C The return type is incompatible with B.execute() QUESTION 10 What is the result? 11. public class Person { 12. String name = "No name"; 13. public Person(String nm) { name = nm; 14. 15. 16. public class Employee extends Person { 17. String empid = "0000"; 18. public Employee(String id) { empid = id; 19.

20. 21. public class EmployeeTest { 22. public static void main(string[] args){ 23. Employee e = new Employee("4321"); 24. System.out.println(e.empID); 25. 26. A. 4321 B. 0000 C. An exception is thrown at runtime. D. Compilation fails because of an error in line 18. Answer: D Implicit super constructor Person() is undefined. Must explicitly invoke another constructor