- Học kỳ
- SP2026
- Thời Gian
- 4/5/26
- Loại tài liệu
- FE
- Mã Đề
- PRO192_SP26_B5RE_291835
PRO192 SP26 B5 FE RE
1. (Choose 1 answer)
Which is a valid keyword in Java?
A. interface
B. include
C. Float
D. Integer
2. (Choose 1 answer)
In binary numbers, how many digits does a byte hold?
A. 16
B. 8
C. 4
D. 2
3. (Choose 1 answer)
What is the meaning of platform-independent?
A. write once, run anywhere
B. not easy to execute on any system after compilation.
C. the execution of the program is restricted by the type of OS environment provided.
D. All of the others
4. (Choose 1 answer)
To run a Java program, which the software must be installed?
A. Java Runtime Environment (JRE)
B. Eclipse
C. Java Development Kit (JDK)
D. Netbeans
5. (Choose 1 answer)
Which of the following types of errors occur during the execution of a program but are due to incorrect program design?
A. Compiler errors
B. Syntax errors
C. Run-time errors
D. Logic errors
6. (Choose 1 answer)
Which of the following is NOT a Java feature?
A. Use of pointers.
B. Ease of learning.
C. It is a secure language.
D. Independent Platform.
7. (Choose 1 answer)
A Java source code will be compiled to the file in which of the following extensions?
A. .class
B. .java
C. .exe
D. .bat
8. (Choose 1 answer)
What is the output?
A. Ab Cd
AB CD
AB EF
Gh
Ab Cd
B. ab cd
AB EF
ab ef Gh
ab ef Gh
C. Ab Cd
AB CD
AB EF
Gh
Ab Cd
D. ab cd
ab ef gh
9. (Choose 1 answer)
Which set correctly lists all the integer primitive data types in Java?
A. byte, short, float, int
B. short, long, byte, int
C. int, short, double, byte
D. long, int, boolean, byte
10. (Choose 1 answer)
What is the output of the following Java code?
public class StringTest { public static void main(String[] args) { String s1 = "hello"; String s2 = new String("hello"); System.out.println(s1 == s2); }
}
A. true
B. false
C. Compile-time error
D. null
11. (Choose 1 answer)
What is the output of the code snippet?
public class Test { public static void main(String[] args) { int result; System.out.println(result = true? 100: 5); } }
A. 100
B. 5
C. 0
D. Runtime error.
12. (Choose 1 answer)
What is the output of the code snippet?
public class Test { public static void main(String[] args) { int[] a = new int[5]; for(int i: a){ i = 1; } System.out.println(a[1]); }
}
A. 0
B. 1
C. null
D. [I@15db9742]
13. (Choose 1 answer)
Which string method is used to split a string using a regular expression?
A. separate()
B. tokenize()
C. split()
D. parse()
14. (Choose 1 answer)
What is a checked exception in Java?
A. Checked exceptions are the ones that are checked during compilation time
B. Checked exceptions are the ones that are checked during the execution time
C. Checked exceptions are syntax errors
D. Checked exceptions are runtime errors
15. (Choose 1 answer)
What is the purpose of Java's wrapper classes?
A. To define GUI elements.
B. To encapsulate primitive types in objects.
C. To create multiple inheritance.
D. To enhance string performance.
16. (Choose 1 answer)
What is the difference between a class and an object?
A. A class is a blueprint to make an object
B. An object is a blueprint to make a class
C. A class is only like an object
D. None of the others
17. (Choose 3 answers)
What are components of a class in Java OOP? Choose multiple correct answers.
A. Constructors are responsible for object creation
B. Attributes, Fields, Properties of a class represents by variables
C. Behaviours, Modification code represent by methods or functions
D. main() method for execution of the class
18. (Choose 1 answer)
Which of the following describes an mutator(setter) method?
A. A method that deletes object data.
B. A method that modifies object data without directly accessing it
C. A method that retrieves object data without changing it.
D. A method that returns nothing.
19. (Choose 1 answer)
What is the output of the following Java code?
(ReferenceTest main calls raiseSalary(20) on an Employee object created with 50000 salary)
A. 50000
B. 52000
C. 60000
D. Compile-time error
20. (Choose 1 answer)
Which of the following is the MOST RESTRICTIVE access level for a class member in Java?
A. protected
B. default (package-private)
C. public
D. private
21. (Choose 1 answer)
What is a subclass in Java inheritance?
A. The class that inherits from another class
B. The class that is inherited from multiple classes
C. The final class in the inheritance chain
D. The class that has abstract methods
22. (Choose 1 answer)
Which of the following is NOT one of the four fundamental object-oriented programming concepts?
A. Abstraction
B. Inheritance
C. Composition
D. Polymorphism
23. (Choose 1 answer)
Consider the provided code involving interfaces Animal, Pet and class Dog, and the test class. What is the output?
A. Compilation error occurs
B. Woof!
Running
Playing fetch
C. Running
Playing fetch
D. Woof!
Running
Playing fetch
24. (Choose 1 answer)
What is the main advantage of using interfaces in Java regarding inheritance?
A. Enable multiple inheritance capability.
B. Provides faster execution speed compared to abstract classes.
C. Automatically generate constructor methods for implementing classes.
D. Allow direct instantiation of interface objects without implementing classes.
25. (Choose 3 answers)
Choose multiple correct answers.
A. The purpose of a getter method in Java is to get the value of a variable
B. The purpose of a setter method in Java is to set the value of a variable
C. return keyword used to define getter and setter method in Java
D. Access modifiers often used for getter or setter method is public
26. (Choose 1 answer)
What is a way to group related classes in Java and it is called a namespace?
A. package
B. file
C. software
D. folder
27. (Choose 1 answer)
Consider a superclass "Shape" with a method "draw()" and a subclass "Circle" that overrides the "draw()" method. If an object of the "Circle" class is declared using the superclass type and the "draw()" method is invoked, what will happen?
A. The "draw()" method of the subclass will be executed.
B. The "draw()" method of the superclass will be executed.
C. A compilation error will occur.
D. The "draw()" method will execute based on the type of the reference variable.
E. Both the "draw()" methods of the superclass and subclass will be executed.
F. The result depends on whether the "draw()" method is static or instance.
28. (Choose 1 answer)
What is the output following the code snippet? (DemoClass with two identical add methods)
A. Compile error
B. 2. Addition of two numbers: 50
C. 1. Addition of two numbers: 50
D. 20, 30
29. (Choose 1 answer)
In Java, can an abstract class have instance variables?
A. Yes, abstract classes can have both instance and static variables.
B. No, abstract classes cannot have instance variables.
C. Yes, but only if the instance variables are declared as "static"
D. Yes, but only if the abstract class has no methods.
30. (Choose 1 answer)
What is the output of the following Java program? (Abstract class A with private int a, b, constructor initializing them, trying to instantiate in Main)
A. 37
B. 12
C. 25
D. Compiler error at statement A m = new A() {};
31. (Choose 2 answers)
Choose multiple correct answers.
A. Inheritance allows a class to inherit the properties and methods of another class
B. The keyword "extends" is used to indicate inheritance in Java. It is used in the declaration of a subclass to specify the superclass that it is inheriting from.
C. A subclass can access the private members of the superclass
D. Java supports both multiple inheritance of classes and interfaces
32. (Choose 1 answer)
Can a subclass override a method that is declared as final in its superclass?
A. Yes, under certain circumstances and a warning will be issued by the compiler.
B. Yes, but a warning will be issued by the compiler.
C. No, a final method cannot be overridden by any subclass.
D. Only if the subclass is in a different package.
33. (Choose 1 answer)
What is the output following code snippet: int sum=0; for(int i=0;i<=10;i++){ sum+= (i%2==0?i:-i); } System.out.println(sum);
A. 5
B. 2
C. The program will raise an exception.
D. 3
34. (Choose 1 answer)
In a banking application, you need to represent customer accounts using object arrays. Which OOP concept allows you to create a blueprint for the Account class?
A. Inheritance
B. Abstraction
C. Encapsulation
D. Polymorphism
E. Composition
F. Interface
35. (Choose 1 answer)
Which of the following statements is used to get the size of a one-dimensional array in Java? Assume that array is given by this statement: int[] arr = new int[100];
A. arr.length
B. arr.length()
C. arr.size
D. arr.size()
36. (Choose 1 answer)
Choose the correct statement related to the encapsulation concept in Java.
A. Data hiding
B. Method hiding
C. Hiding constructor
D. Class hiding
37. (Choose 1 answer)
Which of the following classes is used for shuffling an ArrayList in Java?
A. Collections
B. CollectionList
C. Arrays
D. Array.Util
38. (Choose 1 answer)
All abstract data structures: List, Set, Map is implemented in which of the following types?
A. Interface
B. Abstract class
C. Concrete class
D. Derived class
39. (Choose 1 answer)
Which operation is fastest in LinkedList compared to ArrayList?
A. Accessing an element by index
B. Iterating through the list
C. Inserting or removing elements at the beginning
D. Sorting the list
40. (Choose 1 answer)
You are developing a gaming leaderboard system where each player has a unique score. Discuss how you would utilize a Java collection to maintain the leaderboard, ensuring efficient access to the highest scores while minimizing duplicate entries.
A. Use a PriorityQueue<Player> with a custom comparator for sorting players based on scores.
B. Implement a custom LinkedList class with a doubly-linked list for efficient score updates.
C. Utilize a TreeMap<Integer, Set<Player>> to map scores to sets of players.
D. Choose a LinkedHashSet<Player> to maintain player order while ensuring uniqueness.
E. Design a custom balanced search tree for efficient score-based player retrieval.
F. Utilize a HashMap<Integer, Player> to directly map scores to players.
41. (Choose 1 answer)
What is the output of the following code snippet? Set<Integer> set = new HashSet(); set.add('1'); set.add(2); set.add(3); set.add(1); System.out.println(set.size());
A. 3
B. 4
C. 1
D. 0
42. (Choose 1 answer)
Choose correct answer about anonymous class?
A. A class that is defined without a name and can be instantiated only once
B. The purpose of using an anonymous class is to provide a way to implement an interface or extend a class without explicitly defining a named class.
C. An anonymous class is created using the “new” keyword followed by the name of the interface or class being implemented or extended.
D. Anonymous classes are like local classes except that they do not have a name.
E. All of the others
43. (Choose 1 answer)
What is the size of an ArrayList if capacity is NOT specified during initialization?
A. 0
B. 1
C. 16
D. 10
44. (Choose 1 answer)
Which of the following classes is used to iterate through lines in a text file when reading line by line?
A. BufferedReader
B. FileReader
C. FileInputStream
D. InputStreamReader
45. (Choose 1 answer)
In the object stream, which of the following members of an object won't be serialized?
A. transient variables
B. final variables
C. inherited variables
D. All of the others
46. (Choose 1 answer)
What is the output of the following code snippet? (Reading bytes from test.txt with content 01234567890, reading 4 bytes, outputting the second byte)
A. 1
B. 0
C. 2
D. 3
47. (Choose 1 answer)
Which of the following methods of File class is used to check a file is hidden?
A. isHidden()
B. isDisplay()
C. isWrite()
D. isRead()
48. (Choose 1 answer)
How do you check if a File object refers to a file (NOT a directory) in Java?
A. isFile()
B. checkFile()
C. isNotDirectory()
D. notIsDirectory()
49. (Choose 1 answer)
Which of the following statements is used to add the content to an existing text file?
A. Set the append parameter to true in the constructor of the FileWriter object
B. Set the append parameter to true in the constructor of the File object
C. Set append parameter of true in the constructor of OutputStream object
D. All of the others
50. (Choose 1 answer)
What type of relationship does aggregation describe in object-oriented design?
A. "is a kind of" relationship, indicating inheritance
B. "inherits from" relationship in class hierarchies
C. "uses" relationship, where one class calls another
D. "has a" relationship, showing ownership or containment.
Đính kèm
-
PRO192 SP26 B5 FE RE_40.webp80.5 KB · Lượt xem: 6 -
PRO192 SP26 B5 FE RE_01.webp14.6 KB · Lượt xem: 7 -
PRO192 SP26 B5 FE RE_02.webp15.6 KB · Lượt xem: 2 -
PRO192 SP26 B5 FE RE_03.webp29.9 KB · Lượt xem: 2 -
PRO192 SP26 B5 FE RE_04.webp22.7 KB · Lượt xem: 2 -
PRO192 SP26 B5 FE RE_05.webp27.7 KB · Lượt xem: 2 -
PRO192 SP26 B5 FE RE_06.webp20.6 KB · Lượt xem: 2 -
PRO192 SP26 B5 FE RE_07.webp19.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_08.webp20 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_09.webp24.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_10.webp31.5 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_11.webp27.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_12.webp27.6 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_13.webp20.8 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_14.webp32.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_15.webp24.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_16.webp24.8 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_17.webp37.1 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_18.webp32.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_19.webp29.3 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_20.webp23.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_21.webp25.6 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_22.webp24.9 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_23.webp33 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_24.webp39.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_25.webp35.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_26.webp19.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_27.webp74.4 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_28.webp28.3 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_29.webp35.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_30.webp30.8 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_31.webp43.4 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_32.webp37.6 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_33.webp26.5 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_34.webp36.1 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_35.webp30.6 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_36.webp22.3 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_37.webp21 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_38.webp24.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_39.webp26.1 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_41.webp27.5 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_42.webp53.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_43.webp18.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_44.webp26.5 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_45.webp25.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_46.webp26.7 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_47.webp21.5 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_48.webp22.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_49.webp42.2 KB · Lượt xem: 1 -
PRO192 SP26 B5 FE RE_50.webp35.9 KB · Lượt xem: 6