












































































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 practice exam is for candidates looking to achieve Sun Certified Associate status for Java Platform SE 1.0. The exam tests foundational Java knowledge, including Java syntax, object-oriented programming principles, and Java APIs. It is designed for those who are beginning their journey with Java development.
Typology: Exams
1 / 84
This page cannot be seen from the preview
Don't miss anything!













































































Question 1. Which method serves as the entry point for execution in a standalone Java application? A) static void main(String args[]) B) public void main(String[] args) C) public static void main(String[] args) D) main(String[] args) Answer: C Explanation: The method signature public static void main(String[] args) is required as the entry point so the JVM can invoke it to start the program. Question 2. What is the primary function of the Java Virtual Machine (JVM)? A) Compiling Java code to bytecode B) Interpreting Java source code C) Executing Java bytecode D) Managing operating system resources Answer: C Explanation: The JVM executes Java bytecode, enabling the "Write Once, Run Anywhere" capability. Question 3. Which of the following is a valid Java identifier? A) 2value B) _value C) value# D) class Answer: B Explanation: Identifiers can start with a letter, underscore, or dollar sign; _value is valid.
Question 4. Which file extension is used for compiled Java bytecode? A) .java B) .byte C) .class D) .exe Answer: C Explanation: Java source files are compiled to .class files containing bytecode. Question 5. Which Java keyword is used to define a class? A) void B) static C) class D) object Answer: C Explanation: The class keyword is used to declare a class. Question 6. Which primitive data type is used to represent true or false values? A) int B) boolean C) char D) byte Answer: B Explanation: The boolean type represents logical values true and false.
Question 10. What is the size of the Java byte data type? A) 8 bits B) 16 bits C) 32 bits D) 64 bits Answer: A Explanation: The byte type is an 8-bit signed integer. Question 11. Which of the following statements correctly declares a float variable? A) float x = 3.14; B) float x = 3.14f; C) float x = "3.14"; D) float x = 3; Answer: B Explanation: A float literal must have an f or F suffix. Question 12. Which operator is used for string concatenation in Java? A) * B) + C) & D). Answer: B Explanation: The + operator concatenates strings.
Question 13. Which of the following can be used as the first character of an identifier? A) 9 B) $ C) # D) % Answer: B Explanation: Identifiers can start with a letter, underscore, or dollar sign. Question 14. Which Java primitive type would you use for a variable storing a single Unicode character? A) byte B) char C) short D) boolean Answer: B Explanation: The char type stores a single 16-bit Unicode character. Question 15. What is the output of: System.out.println(2 + 3 + "Test");? A) 5Test B) 23Test C) Test D) Test Answer: A Explanation: 2 + 3 is evaluated first, then concatenated with "Test".
Question 19. Which keyword is used to prevent further subclassing of a class? A) static B) final C) private D) abstract Answer: B Explanation: final prevents a class from being subclassed. Question 20. What does the javac command do? A) Runs a Java application B) Compiles Java source code to bytecode C) Launches the JVM D) Packages Java classes into a JAR Answer: B Explanation: javac is the Java compiler. Question 21. What is the default value of a boolean instance variable? A) true B) false C) 0 D) null Answer: B Explanation: Boolean instance variables default to false.
Question 22. Which of the following correctly creates an array of 5 integers? A) int[5] a; B) int a[] = new int[5]; C) int a = new int[5]; D) int[] a = int[5]; Answer: B Explanation: This is the correct array declaration and instantiation. Question 23. Which access modifier allows a member to be accessed from any class? A) private B) protected C) public D) default Answer: C Explanation: public allows access from any class. Question 24. In Java, how are primitive arguments passed to methods? A) By reference B) By value C) By pointer D) By object Answer: B Explanation: Primitives are passed by value.
Question 28. What does the continue statement do in a loop? A) Exits the loop B) Skips to the next iteration C) Stops program execution D) Causes a compilation error Answer: B Explanation: It skips the rest of the loop body and continues with the next iteration. Question 29. Which of the following is a legal array declaration? A) int arr[]; B) array int[]; C) int[]; D) int arr; Answer: A Explanation: int arr[]; is a valid declaration. Question 30. What is the scope of a variable declared inside a method? A) Class scope B) Method scope C) Package scope D) Block scope Answer: B Explanation: It is only accessible within that method.
Question 31. Which operator is used for casting in Java? A) cast B) as C) (type) D) convert Answer: C Explanation: Casting is done using the (type) syntax. Question 32. Which keyword is used to handle exceptions? A) throw B) try C) catch D) Both B and C Answer: D Explanation: try is for code that may throw, and catch handles the exception. Question 33. What happens when an object no longer has any references in Java? A) It is deleted immediately B) It is garbage collected C) It causes an error D) It remains in memory forever Answer: B Explanation: The garbage collector reclaims memory for unreferenced objects.
Question 37. Which keyword is used to define a constant in Java? A) static B) final C) const D) immutable Answer: B Explanation: final variables cannot be changed, making them constants. Question 38. Which of the following is not a valid Java primitive type? A) float B) double C) integer D) boolean Answer: C Explanation: integer is not a primitive type; int is. Question 39. Which statement is true about the String class? A) Strings are mutable B) Strings are immutable C) Strings can be changed using setChar D) Strings are stored as primitive types Answer: B Explanation: Strings are immutable.
Question 40. Which of the following is the correct way to call a superclass constructor? A) this() B) super() C) parent() D) base() Answer: B Explanation: Use super() to invoke a superclass constructor. Question 41. Which method is automatically called when an object is garbage collected? A) finalize B) cleanup C) destroy D) delete Answer: A Explanation: The finalize method is called by the garbage collector before reclaiming an object's memory. Question 42. Which of the following is the correct way to declare a two-dimensional array? A) int[][] arr; B) int arr[][]; C) int[] arr[]; D) All of the above Answer: D
Explanation: The main method must be static. Question 46. Which statement declares and initializes a long variable? A) long x = 100L; B) long x = 100; C) long x = '100'; D) long x = "100"; Answer: A Explanation: The L suffix distinguishes a long literal. Question 47. What is the purpose of the break statement in a switch block? A) Exit the JVM B) Stop execution of the switch C) Continue the next case D) Skip all cases Answer: B Explanation: break exits the switch block. Question 48. What is the size, in bits, of a Java char? A) 8 B) 16 C) 32 D) 64 Answer: B
Explanation: Java char is a 16-bit Unicode character. Question 49. What does the implements keyword do? A) Inherit from a class B) Implement an interface C) Declare an abstract method D) Override a method Answer: B Explanation: implements declares that a class uses an interface. Question 50. Which method is used to convert a string to uppercase in Java? A) toUpper() B) toUpperCase() C) uppercase() D) upperCase() Answer: B Explanation: toUpperCase() is the correct method. Question 51. What is the value of 10 > 5 in Java? A) true B) false C) 5 D) 10 Answer: A
Explanation: The multiplication operator (*) has higher precedence than +, =, and &&. Question 55. What is the output of System.out.println("Hello".length());? A) 4 B) 5 C) 0 D) 6 Answer: B Explanation: The string "Hello" has a length of 5. Question 56. Which data type is returned by the charAt(int index) method of String? A) int B) char C) byte D) String Answer: B Explanation: charAt returns a char. Question 57. Which keyword is used to define an abstract class? A) final B) static C) abstract D) implements Answer: C
Explanation: abstract marks a class as abstract. Question 58. What is the range of the Java byte type? A) - 128 to 127 B) 0 to 255 C) - 256 to 255 D) - 32768 to 32767 Answer: A Explanation: byte ranges from - 128 to 127. Question 59. Which method is used to extract a substring from a string? A) extract() B) substring() C) subString() D) substr() Answer: B Explanation: substring() is the correct method. Question 60. Which of the following is a checked exception? A) NullPointerException B) ArithmeticException C) IOException D) ArrayIndexOutOfBoundsException Answer: C