Sreejobs Logo
   For Latest Job Updates  
sreenutech.com Online Exams
Home Govt Jobs IT Fresher Jobs IT Exp Jobs IT Walk-Ins MBA Jobs BPO Jobs Register FAQ’s Post Job Contact Us
Search:
SreeJob Fees   Feeds
Hot Jobs
Welcome Guest
Login | Register
Total No Of Questions: 50.
1) Assume the following method is properly synchronized and called from a thread A on an object B:
wait(2000);
After calling this method, when will the thread A become a candidate to get another turn at the CPU?



2) Given:
35. int x = 10;
36. do { 37. x--;
38. } while (x < 10);
How many times will line 37 be executed?



3) Given:
11. public class Person {
12. private String name, comment;
13. private int age;
14. public Person(String n, int a, String c) {
15. name = n; age = a; comment = c;
16. }
17. public boolean equals(Object o) {
18. if (! (o instanceof Person)) return false;
19, Person p = (Person)o;
20. return age == p.age && name.equals(p.name);
21. }
22. }
What is the appropriate definition of the hashCode method in class Person?


4) Given the following,
2. class MyThread extends Thread {
3. public static void main(String [] args) {
4. MyThread t = new MyThread();
5. t.start();
6. System.out.print("one. ");
7. t.start();
8. System.out.print("two. ");
9. }
10. public void run() {
11. System.out.print("Thread ");
12. } }
What is the result of this code?



5)

Given:

1. public class Team extends java.util.LinkedList {
2. public void addPlayer(Player p) {
3. add(p);
4. }
5. public void compete(Team opponent) { /* more code here */ }
6. }
7. class Player { /* more code here */ }

Which two are true? (Choose two.)
A. This code will compile.
B. This code demonstrates proper design of an is-a relationship.
C. This code demonstrates proper design of a has-a relationship.
D. A Java programmer using the Team class could remove Player
objects from a Team object.

Answer: AD

Question: 59
Click the Exhibit button.
11. class Payload {
12. private int weight;
13. public Payload(int wt) { weight = wt; }
13. public void setWeight(mt w) { weight = w; }
15. public String toString { return Integer.toString(weight); }
16. }
17.
18. public class TestPayload {
19. static void changePayload(Payload p) {
20. /* insert code here */
21. }
22.
23. public static void main(String[] args) {
24. Payload p = new Payload();
25. p.setWeight(1024);
26. changePayload(p);
27. System.out.println(”The value of p is “+ p);
28. }
29. }
Which statement, placed at line 20, causes the code to print “The
value of p is 420.”?



6) Which are valid declarations? (Choose all that apply.)


7)

Given:
10. class Line {
11. public class Point { public int x,y;}
12. public Point getPoint() { return new Point(); }
13. }
14. class Triangle {
15. public Triangle() {
16. // insert code here
17. }
18. }

Which code, inserted at line 16, correctly retrieves a local instance of a Point object?



8) Which are true? (Choose all that apply.)


9) Which will compile and run without exception? (Choose all that apply.)


10)

Given:
11. Float pi = new Float(3.14f);
12. if (pi > 3) {
13. System.out.print("pi is bigger than 3. ");
14. }
15. else {
16. System.out.print("pi is not bigger than 3. ");
17. }
18. finally {
19. System.out.println("Have a nice day.");
20. }

What is the result?

Page 1 of 5
Home | Register for Job Updates | Contact Us