Knowee
Questions
Features
Study Tools

Cho biết kết quả của đoạn mã sau:boolean a = false;boolean b = !a;System.out.println(a);System.out.println(b);System.out.println(a&&b);donefalse false truefalse true truefalse true falsetrue false true

Question

Cho biết kết quả của đoạn mã sau:boolean a = false;boolean b = !a;System.out.println(a);System.out.println(b);System.out.println(a&&b);donefalse false truefalse true truefalse true falsetrue false true

🧐 Not the exact question you are looking for?Go ask a question

Solution

Kết quả của đoạn mã trên sẽ là:

false true false

Giải thích:

  • Biến a được khởi tạo với giá trị là false.
  • Biến b được khởi tạo với giá trị là phủ định của a, tức là true.
  • Khi in ra giá trị của a, kết quả là false.
  • Khi in ra giá trị của b, kết quả là true.
  • Khi in ra kết quả của phép toán a&&b (AND logic), kết quả là false vì trong phép toán AND logic, kết quả chỉ trả về true khi cả hai biến đều true. Trong trường hợp này, a là false và b là true nên kết quả là false.

This problem has been solved

Similar Questions

What will be result of the following statement    boolean a= true;    boolean b = false;System.out.println( a&&b);

What is the result of the following code snippet?int x = 10;int y = 5;boolean result = (x > y) && (x != y);System.out.println(result);Question 5Answera.Trueb.Falsec.10d.5

What will be the output of the program?class Test { public static void main(String [] args) { Test p = new Test(); p.start(); } void start() { boolean b1 = false; boolean b2 = fix(b1); System.out.println(b1 + " " + b2); } boolean fix(boolean b1) { b1 = true; return b1; }}true truefalse truetrue falsefalse false

What will be the output of the following code?boolean flag = true;if (flag == false) {    System.out.println("False");} else {    System.out.println("True");}FalseTrueCompilation errorNo output

Cho biết kết quả hiển thị của đoạn mã sau:class TestA{public void start(){System.out.println("TestA");}}class TestB extends TestA{public void start(){System.out.println("TestB");}public static void main(String[] args){((TestA)new TestB()).start();}}doneTestATestBLỗi biên dịchLỗi thực thi

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.