import java.io. * ; import java.io. * ; class TBT { static BufferedReader buf = new BufferedReader(new InputStreamReader(System. in )); public static void main(String args[]) { String m = new String(); float x; m = buf.readLine(); try { x = Float.parseFloat(m); } catch(Exception e) {} } } Cho đoạn chương trình sau:

import java.io. * ;

import java.io. * ;

class TBT {

static BufferedReader buf = new BufferedReader(new InputStreamReader(System. in ));

public static void main(String args[]) {

String m = new String();

float x;

m = buf.readLine();

try {

x = Float.parseFloat(m);

} catch(Exception e) {}

}

}

Cho đoạn chương trình sau:

A. Không thể chuyển đổi một chuỗi sang số thực

B. Biến m,x khai báo trong phương thức main

C. Luồng nhập đặt ngoài cặp lệnh try…catch

D. Biến m,x không khai báo static

Hướng dẫn

Chọn C là đáp án đúng

 

Thư viện tài liệu12 Tháng bảy, 2023 @ 2:37 chiều

Đánh giá chủ đề này
How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site