Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

java

Rating
-
Sold
-
Pages
166
Uploaded on
08-05-2023
Written in
2022/2023

Lecture notes of 166 pages for the course Core java at Core java (java)

Institution
Course

Content preview

310-065




Sun Certified Programmer for the
Java 2 Platform.SE 6.0
Exam: 310-065
Edition: 3.0




© 2008 - 2009 Test Killer, LTD All Rights Reserved

http://www.testkiller.com
1 http://www.troytec.com

, 310-065



QUESTION: 1
Given:
1. public class Threads2 implements Runnable {
2.
3. public void run() {
4. System.out.println("run.");
5. throw new RuntimeException("Problem");
6. }
7. public static void main(String[] args) {
8. Thread t = new Thread(new Threads2());
9. t.start();
10. System.out.println("End of method.");
11. }
12. }
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: D, E

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().


http://www.testkiller.com
2 http://www.troytec.com

, 310-065



Answer: A, F

QUESTION: 3
Given:
7. void waitForSignal() {
8. Object obj = new Object();
9. synchronized (Thread.currentThread()) {
10. obj.wait();
11. obj.notify();
12. }
13. }
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

QUESTION: 4
Click the Exhibit button.
What is the output if the main() method is run?




A. 4
B. 5
C. 8



http://www.testkiller.com
3 http://www.troytec.com

, 310-065



D. 9
E. Compilation fails.
F. An exception is thrown at runtime.
G. It is impossible to determine for certain.


Answer: D

QUESTION: 5
Given:
11. class PingPong2 {
12. synchronized void hit(long n) {
13. for(int i = 1; i < 3; i++)
14. System.out.print(n + "-" + i + " ");
15. }
16. }
17. public class Tester implements Runnable {
18. static PingPong2 pp2 = new PingPong2();
19. public static void main(String[] args) {
20. new Thread(new Tester()).start();
21. new Thread(new Tester()).start();
22. }
23. public void run() { pp2.hit(Thread.currentThread().getId()); }
24. }
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: 6
Given:
1. public class Threads4 {
2. public static void main (String[] args) {
3. new Threads4().go();
4. }
5. public void go() {
6. Runnable r = new Runnable() {
7. public void run() {
8. System.out.print("foo");
9. }


http://www.testkiller.com
4 http://www.troytec.com

Written for

Course

Document information

Uploaded on
May 8, 2023
Number of pages
166
Written in
2022/2023
Type
Class notes
Professor(s)
Hk
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
saiprasad

Get to know the seller

Seller avatar
saiprasad osmania university
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
3
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions