
TN LTM code
Quiz
•
Information Technology (IT)
•
University
•
Easy
BANG P
Used 1+ times
FREE Resource
28 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Đoạn code sau làm gì?
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream();
in.connect(out);
out.write("Hello".getBytes());
byte[] buffer = new byte[5];
in.read(buffer);
System.out.println(new String(buffer));
In ra "Hello"
Gây lỗi IOException
Không in gì do chưa đóng ống dẫn
In ra ký tự rỗng
Answer explanation
Giải thích: Code tạo ống dẫn, ghi chuỗi "Hello" vào PipedOutputStream, đọc lại từ PipedInputStream và in ra.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Lỗi trong đoạn code sau là gì?
try {
PipedOutputStream out = new PipedOutputStream();
out.write("Test".getBytes()); }
catch (IOException e) {
System.out.println("Lỗi I/O");
}
Thiếu import java.io.*
Chưa kết nối PipedOutputStream với PipedInputStream
Sai phương thức write()
Không có lỗi
Answer explanation
Giải thích: PipedOutputStream phải được kết nối với PipedInputStream trước khi ghi dữ liệu.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết quả của đoạn code sau là gì?
Thread thread = new Thread(() -> { System.out.print("X"); });
thread.start();
System.out.print("Y");
Luôn in "XY"
Luôn in "YX"
Có thể in "XY" hoặc "YX" tùy lần chạy
Lỗi biên dịch
Answer explanation
Giải thích: Luồng thread và luồng main chạy song song, thứ tự in không xác định.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Đoạn code sau thiếu gì để đọc dữ liệu từ bàn phím?
BufferedReader reader = new BufferedReader(new InputStreamReader(_______));
String input = reader.readLine();
System.out
System.in
FileInputStream
PipedInputStream
Answer explanation
Giải thích: System.in là luồng nhập tiêu chuẩn từ bàn phím.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Phương thức nào sau đây đóng cả PipedInputStream và PipedOutputStream?
void closePipe(PipedInputStream in, PipedOutputStream out)
{ // Chọn phương thức phù hợp }
in.close(); out.close();
try (in; out) { ... } (Java 9+)
Pipe.closeAll(in, out);
Không cần đóng
Answer explanation
Giải thích: Cú pháp try-with-resources (Java 9+) tự động đóng cả hai luồng.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Đoạn code sau có gì sai?
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream();
out.connect(in);
// Dòng này out.write(65);
Sai thứ tự kết nối (phải là in.connect(out))
Thiếu import
Không bắt IOException
Không có lỗi
Answer explanation
Giải thích: Các phương thức connect() và write() có thể ném IOException.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết quả của đoạn code sau?
try {
int x = 10 / 0;
} catch (ArithmeticException e) {
System.out.print("A");
} catch (Exception e) {
System.out.print("B");
} finally {
System.out.print("C");
}
AC
BC
A
Lỗi biên dịch
Answer explanation
Giải thích: Khối finally luôn chạy sau try/catch.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
30 questions
Tools TIK
Quiz
•
7th Grade - University
30 questions
EVALUASI TENGAH SEMESTER GENAP
Quiz
•
10th Grade - University
30 questions
Introducción a la Sintaxis de Python
Quiz
•
University
23 questions
Python Quiz
Quiz
•
University
24 questions
Machine Learning Quiz
Quiz
•
University
25 questions
Assingment-1 Quiz
Quiz
•
University
25 questions
UJIAN TIK KELAS 4 BULANAN 1
Quiz
•
9th Grade - University
25 questions
Understanding Java Classes and Inheritance - UNIT 1
Quiz
•
University
Popular Resources on Wayground
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
20 questions
MINERS Core Values Quiz
Quiz
•
8th Grade
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
20 questions
Multiplying and Dividing Integers
Quiz
•
7th Grade
10 questions
How to Email your Teacher
Quiz
•
Professional Development
15 questions
Order of Operations
Quiz
•
5th Grade
Discover more resources for Information Technology (IT)
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
7 questions
Central Idea of Informational Text
Interactive video
•
4th Grade - University
20 questions
Physical or Chemical Change/Phases
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
39 questions
Unit 7 Key Terms
Quiz
•
11th Grade - University
7 questions
Transition Words and Phrases
Interactive video
•
4th Grade - University
18 questions
Plotting Points on the Coordinate Plane
Quiz
•
KG - University
5 questions
Declaration of Independence
Interactive video
•
4th Grade - University
