Java Programming
Harvard University
All 3 results
Sort by
-
Exam (elaborations) java programming(Java Never Ends)
- Exam (elaborations) • 6 pages • 2023
- Available in package deal
-
- $8.00
- + learn more
1. Because sleep is a static method, how can it possibly know what thread it needs 
to pause? 
4. Here is some code that synchronizes thread access to a shared variable. How 
come it is not guaranteed to output 30,000 every time it is run? 
public class Counter 
{ 
private int counter; 
public Counter() 
{ 
counter = 0; 
} 
public int value() 
{ 
return counter; 
} 
public synchronized void increment() 
{ 
counter++; 
} 
} 
public class RaceConditionTest extends Thread 
{ 
private Counter countO...
-
Generics and the ArrayList Class in java
- Exam (elaborations) • 9 pages • 2023
- Available in package deal
-
- $8.00
- + learn more
Generics and the ArrayList Class in java 
1. Suppose list is an object of the class ArrayList<String> . How do you add 
the string "Hello" to the ArrayList list ? 
2. Suppose instruction is an object of the class ArrayList<String> that contains 
the string "Stop" at index position 5 . How do you change the string at index 
position 5 to "Go" (without changing any of the elements at other positions)? 
3. Suppose instruction is an object of the class ArrayList<String> that ...
-
Exam (elaborations) java programming
- Exam (elaborations) • 9 pages • 2023
- Available in package deal
-
- $7.99
- + learn more
1. 	What output is produced by the following lines? 
String s = "Hello" + "Joe"; 
Sln(s); 
2. 	Write Java statements that will cause the following to be written to the screen: 
One two buckle your shoe. 
Three four shut the door. 
3.	 What is the difference between Sln and S ? 
4.	 What is the output produced by the following lines? 
Sln(2 + " " + 2); 
Sln(2 + 2); 
5. 	What output is produced by the following code? 
String aString = "Jelly beans"; 
Sln("START0"); 
Sf("START%sEND %n",...
As you read this, a fellow student has made another $4.70
How did he do that? By selling his study resources on Stuvia. Try it yourself! Discover all about earning on Stuvia