Worksheets Name
TCS Java / PLSQL / SQL Mock Class
Total questions: 25
Worksheet time: 25mins Date
1. 1. Which of the following is used to compare two Strings in Java for equality?
a) A) == b) B) .compareTo()
c) C) .equals() d) D) .compare()
2. What is the output of the following code snippet? public class Test { public static void main(String[] args) { int x = 5; int y = 10; System.out.println(x >
y ? x : y); } }
a) A) 5 b) B) 10
c) C) true d) D) false
3. 3. Which of the following is NOT a Java keyword?
a) A) synchronized b) B) transient
c) C) include d) D) volatile
4. Which method is called to start a thread in Java?
a) A) run() b) B) begin()
c) C) execute() d) D) start()
5. Which of the following can be used to handle multiple exceptions in a single catch block?
a) A) Using multiple catch blocks b) B) Using a single catch block with | operator
c) C) Using nested try statements d) D) Using the & operator in catch
6. Which of the following collection types is ordered and allows duplicate elements?
a) A) Set b) B) List
c) C) Map d) D) Queue
7. Which of these is the correct way to declare an array in Java?
a) A) int[] arr = new int[5]; b) B) int arr[5];
c) C) array int arr[5]; d) D) int arr();
8. What is the output of the following code? public class Test { public static void main(String[] args) { int i = 0; for (System.out.println("Start"); i < 3; i++) {
System.out.println(i); } } }
a) A) Compilation error b) B) Start, 0, 1, 2
c) C) 0, 1, 2 d) D) Start, 1, 2, 3
9. What will be the output of the following code? public class Test { public static void main(String[] args) { String s1 = "Java"; String s2 = "Java";
System.out.println(s1 == s2); } }
a) A) true b) B) false
c) C) null d) D) Compilation error
10. Which of the following modifiers makes a class visible to all other classes within the same package?
a) A) protected b) B) public
c) C) private d) D) package-private (no modifier)
11. Which of the following statements is true about the finally block?
a) A) finally is optional and is executed only if no exceptions are thrown. b) B) finally is executed only if an exception is thrown.
c) C) finally is always executed, regardless of whether an exception is d) D) finally must contain code to close the exception.
thrown.
12. Which of these statements is true about the HashMap collection in Java?
a) A) It maintains the insertion order of elements. b) B) It allows duplicate keys.
c) C) It is synchronized. d) None of these
13. In Java, which keyword is used to refer to the current instance of a class?
a) A) that b) B) this
c) C) super d) D) instance
14. public class Test { public static void main(String[] args) { System.out.println(Math.min(Double.MIN_VALUE, 0.0d)); } }
a) A) 0.0 b) B) Double.MIN_VALUE
c) C) Compilation error d) 0
15. Which of the following is true about the final keyword in Java?
a) A) It allows a method to be overridden. b) B) It can be used with classes, methods, and variables.
c) C) It makes a class inheritable. d) D) It is used to define abstract methods.
16. What is the correct syntax for declaring a variable in PL/SQL?
a) A) variable_name := datatype; b) B) datatype variable_name;
c) C) variable_name datatype; d) D) variable_name datatype := value;
17. Which SQL statement is used to retrieve data from a database?
a) A) SELECT b) B) GET
c) C) FETCH d) D) EXTRACT
18. Which clause is used to filter records in an SQL query?
a) A) ORDER BY b) B) GROUP BY
c) C) WHERE d) D) HAVING
19. Which of the following SQL keywords is used to sort the result-set in ascending or descending order?
a) A) ORDER BY b) B) SORT BY
c) C) GROUP BY d) D) FILTER BY
20. In SQL, which operator is used to check for the existence of a value in a subquery?
a) A) IN b) B) BETWEEN
c) C) EXISTS d) D) LIKE
21. Which of the following is NOT a PL/SQL data type?
a) A) VARCHAR2 b) B) BOOLEAN
c) C) INTEGER d) D) LIST
22. What will the following SQL query return? SELECT * FROM employees WHERE salary BETWEEN 50000 AND 100000;
a) A) Employees with salary less than 50,000 b) B) Employees with salary more than 100,000
c) C) Employees with salary between 50,000 and 100,000 inclusive d) D) Employees with salary equal to 50,000 and 100,000 only
23. What does the SQL statement SELECT DISTINCT do?
a) A) It selects rows with only unique values in the specified columns. b) B) It filters the records based on conditions.
c) C) It orders the results. d) D) It removes duplicates permanently from the table.
24. Which keyword is used to declare an exception handler in PL/SQL?
a) A) WHEN b) B) EXCEPTION
c) C) HANDLE d) D) CATCH
25. In PL/SQL, which of the following is true about stored procedures?
a) A) They cannot accept parameters. b) B) They return a single value.
c) C) They can be called with or without parameters. d) D) They must return a value.
Answer Keys
1. c) C) .equals() 2. b) B) 10 3. c) C) include
4. d) D) start() 5. b) B) Using a single catch block with | 6. b) B) List
operator
7. a) A) int[] arr = new int[5]; 8. b) B) Start, 0, 1, 2 9. a) A) true
10. d) D) package-private (no modifier) 11. c) C) finally is always executed, regardless 12. d) None of these
of whether an exception is thrown.
13. b) B) this 14. a) A) 0.0 15. b) B) It can be used with classes, methods,
and variables.
16. d) D) variable_name datatype := value; 17. a) A) SELECT 18. c) C) WHERE
19. a) A) ORDER BY 20. c) C) EXISTS 21. d) D) LIST
22. c) C) Employees with salary between 23. a) A) It selects rows with only unique 24. b) B) EXCEPTION
50,000 and 100,000 inclusive values in the specified columns.
25. c) C) They can be called with or without
parameters.