P. 1
Sas

# Sas

|Views: 142|Likes:

See more
See less

08/22/2012

pdf

text

original

# Câu hỏi Ôn Tập Quarter 4

1. What types of values are stored in a node of a doubly-linked list? a. Only dada contained in the node b. Address of the succeeding node only along with some data c. Address of the preceding node only along with some data d. Address of the preceding and succeeding node with some data 2. Which of the following is an example of a recursive function? a. f(n) = 0 where n >1; and f(1) =1 b. f(n +1) = n where n >1; and f(1) =1 c. f(n) = n where n >1; and f(1) =1 d. f(n) = f(n - 1) +n where n >1; and f(1) =1 3. In a binary tree, a node with no children is call a……….. a. Subtree b. Parent node c. Internal node d. Leaf node 4. Which of the following is NOT correct about assertion? a. Assertions are a way to test certain assumtions about the logic of a program b. Assertions occupy space in class file and increases the download time c. Assertions describe how to hanle unexpected errors d. Assertions can be enabled during program development 5. Which of the following is a condition for queue overflow? a. FRONT = 1 and REAR = last index position b. FRONT = REAR c. FRONT = 0 and REAR = last index position d. FRONT = 0 and REAR = first index position 6. Which of the following method will you call to set the size of a Frame ? a. Pack() b. setVisible() c. setSize() d. setLayout()
Good Luck Page 1

Identify the correct algorithm that would enable Henry to insert values at the end of the linked list. 1. Make the next field of LAST point to the new node 5. Make the next field of LAST point to the new node 5. a. Make LAST point to the new node c. Alloacte memory for the new node 2. Make LAST point to NULL c. According to the requirement. to keep track of the first and the last nodes in the list. then: a. Assign value to the data field of the new node 3. Henry has to write a program to store and display a list of prime numbers in a singly-linked list. 1. START and LAST. Mark the new node as START 6. Assign value to the data field of the new node 3. then: a. Therefore Hanry decides to use two variables. Alloacte memory for the new node 2. 1. 1.7. Assign value to the data field of the new node 3. Assign value to the data field of the new node 3. Alloacte memory for the new node 2. Make the next field of the new node point to NULL c. Make the next field of the new node point to NULL b. Go to step 6 Good Luck Page 2 . the insert operation always need to be done at the end of the list. Alloacte memory for the new node 2. Make LAST point to the new node c. Make START point to the new node b. If START is NULL. then: a. Make LAST point to the new node c. If START is NULL. Make START point to the new node b. then: a. If START is NULL. Make START point to the new node b. Make START point to the new node b. If START is NULL. Make the next field of START point to the new node 5. Go to step 6 4. Mark the new node as LAST 6. Mark the new node as LAST Make the next field of the new node point to NULL d. Go to step 6 4. Go to step 6 4.

println(4). Statement A is false while Statement B is true c.out. case 1: system. break. case 3: system. Both Statement A and Statement B are false b.out.println(1). 10 1 2 3 b. a. 10 1 2 d.Statement A: You can create a new thread by extending the Thread class Statement B: You can create a new thread by implementing the Runnable interface Select the correct option for the preceding staterents. 1 2 Good Luck Page 5 } . } } What is the output of given code? a.out.out.prinln(3).println(10). case 2: system.out. 10 1 2 3 4 c. if(x>15)x=1.Consider the code: public class TestSwitch{ public static void main(String args[]){ int x = 10. Statement A is true while Statement B is false 13.println(2). default: system. Both Statement A and Statement B are true d. switch(x){ case 10: system. break.

As a part of the development team. point to the new node //Front keeps track of the element that was inserted first Good Luck Page 6 . Class A has a method defined as accessMe(). Front. point to the new node //Front keeps track of the element that was inserted first • Make a variable/ pointed. if the list is empty execute the following steps: • Make a variable/pointer. Protected friend b. What is the access specifier defined to accessMe() method? a.Sam works as a techical support officer in BlueMoon Inc. Protected d. Class X is with n the sme package as Class A where as class Y is in some other package. Make the next field of REAR point to the new node 6. Allocate memory for the new node. Allocate memory for the new node. you are assigned a task to solve this problem by writing an appropriate algorithmn to store the queries in the form of a singly-linked lit. This node would represent a new query 2.related queries on daily basis. The method accessMe() is accessible to class X but not to class Y. which need to be manaced in such a way so that the query that comes firs should be solved first. Rear. point to the new node// Rear keeps track of the element that was inserted last • Exit 5. if the list is empty execute the following steps: • Make a variable/pointer. 1. Make the next field of the rew node point to Null 4. Front. Make the next field of the new node point to Null 4.14. Make FRONT point to the new node b. Private 15. Assign value to the data field of the new node 3. Assign value to the data field of the new node 3.Class X and Y are the sub classes of class A. I receives a lot of hardware. Friendly c. a. This node would represent a new query 2. 1. The algorithm should store the incoming queries in such a way so that the quer. which should be implement to accomplish this task.

io. Make FRONT point to the new node 16.read())!= -1){ out.FileInputStream. import java.txt"). public class Example { public static void main (String [] args)throws IOException{ FileInputStream in = null. while((c=in.• Make a variable/ pointed.IOException. point to the new node //Front keeps track of the element that was inserted first • Make a variable/ pointed. if the list is empty execute the following steps: • Make a variable/pointer. try{ in = new FileInputStream("OutputFile. } } finally{ if(in != null){ Good Luck Page 7 .write(c). Make the next field of the rew node point to Null 4. FileOutputStream out = null.Consider the following code: import java.txt"). import java. Allocate memory for the new node. This node would represent a new query 2. Assign value to the data field of the new node 3.io. Make the next field of FRONT point to the new node 6. Make REAR point to the new node c. Front. point to the new node// Rear keeps track of the element that was inserted last • Exit 5.FileOutputStream. Rear. Make the next field of REAR point to the new node 6.io. int c. Rear. out = new FileOutputStream("InputFile. point to the new node// Rear keeps track of the element that was inserted last • Exit 5. 1.

and display the word Hello? a. The code will copy the content of the InpuText.txt file 17. Both the Statement are False 19. Statement A is True and Statement B is False b. } if(out != null){ out. Both the Statement are True c.txt file to the OutputText.txt file d. The code will copy the content of the OutputFile. Assuming the base address to be 10 and the size of an element to be 2.Consider the following statements: Statement A: An Error class is derived from an Exception class Statement B: Error class is used for VirtualMachineError Which of the following options is true with respect to above statement? a. The code will throw a runtime exception c. 280 d. Statement A is False and Statement B is True d.txt file to the InputFile.close(). 92 c. } } What will be the output of the above? a.close(). 29 b. 28 18. Which of the following code will compile. a. Jim wants to calculate the address of an element stored at 9th position in an array. The code will execute without any output b.} } in. public class Example{ public static void main(String args[]){ Good Luck Page 8 . calculate the address of an element stored 9th position in an array. execute.

If (str1 == str2){ System. String str2 =”Hello”.equals(str2)){ System. If (str1 == str2){ String str2 = new String(“Hello”).println(“Hello”). boolean Page 9 Good Luck . String str2 =”Hello”.println(“Hello”). if(num1 == num2){ System. public class Example{ public static void main(String args[]){ String str1 =”Hello”.println(“Hello”). } } } c. } } } b.out. public class Example{ public static void main(String args[]){ int num1.String str1 =”hello”.out. int num2.println(“Hello”).out. public class Example{ public static void main(String args[]){ String str1 =”Hello”. } } } 20. If (str1. System.Which option shows the allowed data type of a variable in the swith-case construct? a. String str2 =”Hello”. } } } d.out.

FocusEvent 26. A and B. 7 c. AWTEvent c.Conisder the following statements: Statement A: A List can contain duplicate elements Statement B: A Set contains unique elements Which of the following is True. 8 d. How many edges are therer in this binary tree? a. with respect to the above Statement? a. java<filename>. ActionEvent d. Constant c.java Good Luck Page 10 b. then the algorithm has a _____ order of growth. Both. Bubble Sort c.Which of the Statement is used to run a java code? a. java<filename> c. c. if the list to be sorted is small in size and is nearly sorted? a. 6 23. javac<filename>. a. d. are True b. Logarthmic 25. Statement A is False and Statement B is True. 24. are True d. A and B. Log Linear b. Statement. Statement A is True and Statement B is False c. If an algorithm is of the order of O (log n). Statement. Both. 9 b. Selection Sort 22._______is the immediate superclass of the MouseEvent class a. Which of the following sorting techniques will use. byte double .Consider a binary tree consisting of 8 nodes. Insertion Sort b. InputEvent b. Exponential d.java b. Quick Sort d.Float 21.