




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This preparation guide addresses application development fundamentals. Topics include programming logic, data structures, application design, debugging, testing, and software lifecycle concepts across modern platforms.
Typology: Exams
1 / 155
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which of the following best describes encapsulation in object‑oriented programming? A) Inheriting behavior from a parent class B) Hiding internal state and exposing it only through methods C) Allowing a method to have multiple signatures D) Defining a class without any fields Answer: B Explanation: Encapsulation bundles data and the methods that manipulate that data, restricting direct access to the internal representation. Question 2. In Java, which access modifier allows members to be accessed only within the same package and by subclasses in other packages? A) private B) protected C) public D) default (package‑private) Answer: B Explanation: The protected modifier grants package‑level access and also permits subclasses outside the package to access the member. Question 3. What is the result of the following expression in Java? int result = 5 + 2 * 3; A) 21 B) 11 C) 9
Answer: B Explanation: Multiplication has higher precedence than addition, so 2 * 3 = 6; then 5 + 6 = 11. Question 4. Which of the following is a correct way to create a one‑dimensional array of ten integers in Java? A) int[] arr = new int[10]; B) int arr = new int[10]; C) int[10] arr = new int[]; D) int arr[10] = new int; Answer: A Explanation: The syntax type[] name = new type[size]; declares and allocates an array. Question 5. Which of the following statements about method overloading is true? A) Overloaded methods must have different return types only. B) Overloaded methods must differ in parameter list (type, number, or order). C) Overloaded methods can differ only by access modifier. D) Overloaded methods cannot be static. Answer: B Explanation: Overloading is resolved at compile time based on the method’s signature, i.e., its parameter list. Question 6. In Java, what does the final keyword applied to a method indicate?
A) true B) false C) Compilation error D) Runtime exception Answer: A Explanation: Integer values between – 128 and 127 are cached, so a and b refer to the same object; == compares references and returns true. Question 9. Which operator in Java is used for conditional (ternary) evaluation? A) ?: B) ?? C) && D) !! Answer: A Explanation: The ternary operator condition? expr1 : expr2 selects one of two expressions based on a boolean condition. Question 10. Which of the following statements about the switch statement in Java is correct (Java 14 and later)? A) A switch can only work with int and char types. B) switch can be used as an expression that returns a value. C) break is mandatory after every case. D) default must appear first.
Answer: B Explanation: Since Java 14, switch can be used as an expression, yielding a value from the selected case. **Question 11. What is the output of the following loop?
for (int i = 0; i < 5; i++) { if (i == 3) continue; System.out.print(i); } ```** A) 01234 B) 0123 C) 0124 D) 0134 Answer: C Explanation: When `i` equals 3, `continue` skips the print statement; thus the numbers printed are 0,1,2,4. **Question 12. Which of the following best describes the difference between `ArrayList` and `LinkedList` in Java?** ## Certification Exam Preparation Answer: B Explanation: Autoboxing is the automatic conversion between primitives and their corresponding wrapper classes. **Question 15. Which of the following is NOT a valid way to declare a constant in Java?** A) `static final int MAX = 10;` B) `final int MAX = 10;` C) `const int MAX = 10;` D) `public static final int MAX = 10;` Answer: C Explanation: Java does not have a `const` keyword; constants are declared using `final`. **Question 16. What does the `this` keyword refer to inside an instance method?** A) The current class object B) The superclass of the current class C) The method’s return type D) The package name Answer: A Explanation: `this` is a reference to the current object whose method or constructor is being invoked. **Question 17. Which of the following statements about inheritance in Java is false?** A) A class can extend only one superclass. B) A subclass inherits private members of its superclass. ## Certification Exam Preparation C) Constructors are not inherited. D) Methods can be overridden in a subclass. Answer: B Explanation: Private members are not accessible to subclasses; they are inherited but not visible. **Question 18. Which of the following best describes polymorphism in Java?** A) The ability of a class to have multiple constructors. B) The ability of a method to have multiple return types. C) The ability of an object to take many forms, typically via method overriding or interface implementation. D) The ability to hide data using private fields. Answer: C Explanation: Polymorphism allows a single interface to represent different underlying forms (classes), achieved through overriding and interfaces. **Question 19. What will be the output of the following code snippet? ```java String s1 = "Hello"; String s2 = new String("Hello"); System.out.println(s1 == s2); ```** ## Certification Exam Preparation Explanation: `StringBuilder` is mutable and not synchronized, making it faster than `StringBuffer` when thread safety is not required. **Question 22. In Java, which exception is thrown when an attempt is made to access an array with an illegal index?** A) `NullPointerException` B) `ArrayIndexOutOfBoundsException` C) `IllegalArgumentException` D) `ClassCastException` Answer: B Explanation: Accessing an array with an index outside its bounds triggers `ArrayIndexOutOfBoundsException`. **Question 23. Which of the following statements correctly creates a thread by extending the `Thread` class?** A) `class MyThread implements Runnable { public void run() {} }` B) `class MyThread extends Thread { public void run() {} }` C) `Thread t = new Thread(); t.start();` D) `Runnable r = new Thread();` Answer: B Explanation: Extending `Thread` and overriding `run()` defines a thread’s execution logic. **Question 24. What is the purpose of the `finally` block in a try‑catch‑finally construct?** A) To catch exceptions not handled by previous catch clauses. ## Certification Exam Preparation B) To execute code regardless of whether an exception was thrown. C) To re‑throw the caught exception. D) To define a default return value. Answer: B Explanation: The `finally` block always executes after try/catch, even if an exception occurs or the method returns. **Question 25. Which of the following statements about Java’s garbage collector is false?** A) It automatically frees memory occupied by objects that are no longer reachable. B) It can be invoked explicitly using `System.gc()`. C) It guarantees immediate reclamation of memory. D) It runs as a background thread. Answer: C Explanation: The garbage collector runs nondeterministically; calling `System.gc()` only suggests reclamation, not guarantees it. **Question 26. In JDBC, which method of `Statement` is used to execute a query that returns a `ResultSet`?** A) `executeUpdate()` B) `executeQuery()` C) `execute()` D) `executeBatch()` Answer: B ## Certification Exam Preparation ## D) CONNECT Answer: B Explanation: GET, PUT, DELETE, HEAD, OPTIONS are idempotent; repeated requests have the same effect. POST is not. **Question 30. Which of the following best describes a RESTful web service?** A) Uses SOAP envelope for messaging. B) Relies on XML exclusively for data exchange. C) Operates over HTTP using standard verbs and stateless interactions. D) Requires a WSDL file for client generation. Answer: C Explanation: REST uses HTTP verbs (GET, POST, etc.), stateless communication, and can exchange JSON, XML, etc. **Question 31. In Java Servlets, which method is called by the container to handle an HTTP GET request?** A) `doPost()` B) `doGet()` C) `service()` D) `init()` Answer: B Explanation: `doGet(HttpServletRequest, HttpServletResponse)` processes GET requests. ## Certification Exam Preparation **Question 32. Which of the following is a common vulnerability that allows attackers to inject malicious SQL code?** A) Cross‑Site Scripting (XSS) B) SQL Injection C) Buffer Overflow D) Man‑in‑the‑Middle Answer: B Explanation: SQL injection occurs when unsanitized user input is concatenated into SQL statements. **Question 33. Which Java annotation is used to indicate that a method is a unit test when using JUnit 5?** A) `@TestMethod` B) `@UnitTest` C) `@Test` D) `@JUnit` Answer: C Explanation: `@Test` marks a method as a test case in JUnit. **Question 34. Which of the following statements about the `static` keyword in Java is false?** A) A static method can be called without creating an instance of the class. B) Static variables are shared among all instances of the class. C) A static method can directly access non‑static instance variables. D) Static blocks are executed when the class is first loaded. ## Certification Exam Preparation A) An enum can extend another class. B) Enums are implicitly final and cannot be subclassed. C) Enums can be instantiated with the `new` keyword. D) Enums cannot have methods. Answer: B Explanation: Enums are implicitly final; they cannot be subclassed. They can have methods and fields but cannot be instantiated with `new`. **Question 38. In a `for` loop, which part is optional?** A) Initialization statement B) Termination condition C) Increment/decrement statement D) All of the above can be omitted Answer: D Explanation: Any of the three parts may be omitted, resulting in an infinite loop if the condition is omitted. **Question 39. Which of the following is a correct way to catch multiple exception types in a single `catch` block (Java 7+)?** A) `catch (IOException | SQLException ex) {}` B) `catch (IOException, SQLException ex) {}` C) `catch (IOException ex) | (SQLException ex) {}` D) `catch (IOException & SQLException ex) {}` ## Certification Exam Preparation Answer: A Explanation: The multi‑catch syntax uses the pipe (`|`) to list exception types. **Question 40. Which Java keyword is used to refer to the immediate parent class constructor?** A) `this` B) `super` C) `base` D) `parent` Answer: B Explanation: `super()` calls a constructor of the superclass. **Question 41. Which of the following statements about Java’s `HashMap` is false?** A) It allows one null key. B) It maintains insertion order. C) It provides O(1) average time for get/put. D) It is not synchronized. Answer: B Explanation: `HashMap` does not guarantee any ordering; `LinkedHashMap` maintains insertion order. **Question 42. In Java, what does the `transient` keyword indicate when applied to a field?** A) The field cannot be accessed outside its class. B) The field should be ignored during serialization. ## Certification Exam Preparation Explanation: `volatile` forces reads/writes to go directly to main memory, ensuring visibility but not atomicity. **Question 45. Which of the following is a correct way to declare a two‑dimensional array of integers with 3 rows and 4 columns?** A) `int[][] matrix = new int[3][4];` B) `int[3][4] matrix = new int[][];` C) `int matrix[3][4] = new int[3][4];` D) `int[][] matrix = new int[4][3];` Answer: A Explanation: The syntax `type[][] name = new type[rows][columns];` correctly allocates a 2‑D array. **Question 46. Which Java feature allows a class to implement multiple inheritance of type?** A) Extending multiple classes B) Implementing multiple interfaces C) Using abstract classes only D) None of the above Answer: B Explanation: Java does not support multiple class inheritance, but a class can implement many interfaces, achieving multiple inheritance of type. **Question 47. In JDBC, which interface provides methods to navigate and manipulate the result set cursor?** A) `Statement` ## Certification Exam Preparation B) `ResultSet` C) `PreparedStatement` D) `Connection` Answer: B Explanation: `ResultSet` offers methods like `next()`, `previous()`, `absolute(int)`, etc., to move the cursor. **Question 48. Which of the following HTTP status codes indicates that the request was successful and a new resource was created?** A) 200 OK B) 201 Created C) 202 Accepted D) 204 No Content Answer: B Explanation: 201 is returned when a POST request results in creation of a new resource. **Question 49. Which of the following is a correct way to prevent SQL injection when using JDBC?** A) Concatenating user input directly into the SQL string. B) Using `Statement` with string concatenation. C) Using `PreparedStatement` with parameter placeholders. D) Encoding the entire SQL statement in Base64. Answer: C