Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. Quiz One
  2. 1. The output of this program can begin with 4 or 5 or 6.
  3. 2. The output of this program will always end with 5.
  4. 3. There is a scenario in which the output of the program can begin with 5 5.
  5. 4. A ReentrantLock was declared as a field of the class Alpha, and defined as a member of its created objects. The code contained within the body of Alpha's methods decrement () and increment () was enclosed within a pair of lock () and unlock () method calls. The output of the modified program cannot begin with 5. The program was further modified by placing a call to sleep (100) after the statement increment () in the run () method of Incrementor.
  6. 5. There is no scenario in which the output can begin with 4.
  7. 6. There is no scenario in which the output can begin with 5.
  8. 7. There is a scenario in which the output can begin with 6.
  9. 8. There is a scenario in which the output can end with 5.
  10. 9. There is not a scenario in which the output can end with 4
  11. 10. There is not a scenario in which the output can end with 6
  12. Quiz Two
  13. • Try to avoid throwing exceptions. Try, catch works better.
  14. • Preferred to not use Port 80.
  15. • Output Stream Does not have a println method.
  16. • Threads take attributes, i.e. Thread t = new Thread(variable);
  17. • Correct syntax for Creating sockets are Socket s = new Socket(variable, port)
  18. • Correct syntax for the start method is object.Start(); no variable
  19. • Public Service (Socket s) is correct syntax.
  20. • S = this.s; is incorrect, referencing the same variable name.
  21. • Public void run () throws IOException is incorrect, try, catch more affective.
  22. • Correct syntax for getInputStream is inputstreamName = socketName.getInputStream();
  23. • Correct Syntax for getOutputStream is outputstreamName = socket.getOutputStream();
  24. • Scanner = new Scanner(inputstreamName) is correct syntax
  25. • PrintWriter = new PrintWriter(outputsteamname) is correct syntax.
  26. • justDoit() was not instantiated with a need for an argument.
  27. • Correct syntax for closing a socket is. Socketname.close();
  28. • Correct syntax for scanner finding next character, is ScannerName.hasNextLine();
  29. • Correct syntax for the flush method is printWriterName.flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement