Tìm kiếm:
TRANG NHÀ
Giới thiệu VNEDU.ORG
Điều khoản và bản quyền
Liên lạc VNEDU
TRẮC NGHIỆM TRỰC TUYẾN
---Công Cụ:---
Soạn Biểu thức
Bảng màu HTML
Ký hiệu đặc biệt 01
Ký hiệu đặc biệt 02
Ký hiệu đặc biệt 03
Ký hiệu đặc biệt 04
Ký hiệu đặc biệt 05
Ký hiệu đặc biệt 06
Ký hiệu đặc biệt 07
Ký hiệu đặc biệt [Toán]
Tin Học   ||  Căn Bản    Văn Phòng    Hệ Thống - Mạng    Phần Mềm Ứng Dụng    Kỹ thuật số    Lập trình    SQL  

Trắc Nghiệm Java - Bài 30
Ngày làm bài: Hôm nay lúc 21:22:44 (Server time)
Số câu hỏi: 10.   Tổng điểm: 10
Yêu cầu hoàn thành: 60 phút.
Thời gian còn lại: 
Cỡ chữ câu hỏi:  Cỡ chữ đáp án:


1-
Which statement is true?
  A - 
Calling Runtime.gc() will cause eligible objects to be garbage collected.
  B - 
The garbage collector uses a mark and sweep algorithm.
  C - 
If an object can be accessed from a live thread, it can't be garbage collected.
  D - 
If object 1 refers to object 2, then object 2 can't be garbage collected.
2-
What will be the output of the program?
public class Test 
{  
    public static void main(String[] args) 
    { 
        int x = 0;  
        assert (x > 0) ? "assertion failed" : "assertion passed" ; 
        System.out.println("finished");  
    } 
}

  A - 
finished
  B - 
Compiliation fails.
  C - 
An AssertionError is thrown and finished is output.
  D - 
An AssertionError is thrown with the message "assertion failed."
3-
public class Test 
{ 
    public void foo() 
    {
        assert false; /* Line 5 */
        assert false; /* Line 6 */
    } 
    public void bar()
    {
        while(true)
        {
            assert false; /* Line 12 */
        } 
        assert false;  /* Line 14 */
    } 
}
What causes compilation to fail?
  A - 
Line 5
  B - 
Line 6
  C - 
Line 12
  D - 
Line 14
4-
What will be the output of the program?
public class Test 
{
    public static int y;
    public static void foo(int x) 
    {
        System.out.print("foo ");
        y = x;
    }
    public static int bar(int z) 
    {
        System.out.print("bar ");
        return y = z;
    }
    public static void main(String [] args ) 
    {
        int t = 0;
        assert t > 0 : bar(7);
        assert t > 1 : foo(8); /* Line 18 */
        System.out.println("done ");
    }
}

  A - 
bar
  B - 
bar done
  C - 
foo done
  D - 
Compilation fails
5-
What will be the output of the program (when you run with the -ea option) ?
public class Test 
{  
    public static void main(String[] args) 
    {
        int x = 0;  
        assert (x > 0) : "assertion failed"; /* Line 6 */
        System.out.println("finished"); 
    } 
}

  A - 
finished
  B - 
Compilation fails.
  C - 
An AssertionError is thrown.
  D - 
An AssertionError is thrown and finished is output.
6-
public class Test2 
{
    public static int x;
    public static int foo(int y) 
    {
        return y * 2;
    }
    public static void main(String [] args) 
    {
        int z = 5;
        assert z > 0; /* Line 11 */
        assert z > 2: foo(z); /* Line 12 */
        if ( z < 7 )
            assert z > 4; /* Line 14 */

        switch (z) 
        {
            case 4: System.out.println("4 ");
            case 5: System.out.println("5 ");
            default: assert z < 10;
        }

        if ( z < 10 )
            assert z > 4: z++; /* Line 22 */
        System.out.println(z);
    }
}
which line is an example of an inappropriate use of assertions?
  A - 
Line 11
  B - 
Line 12
  C - 
Line 14
  D - 
Line 22
7-
Which of the following statements is true?
  A - 
If assertions are compiled into a source file, and if no flags are included at runtime, assertions will execute by default.
  B - 
As of Java version 1.4, assertion statements are compiled by default.
  C - 
With the proper use of runtime arguments, it is possible to instruct the VM to disable assertions for a certain class, and to enable assertions for a certain package, at the same time.
  D - 
When evaluating command-line arguments, the VM gives -ea flags precedence over -da flags.
8-
Which statement is true?
  A - 
Assertions can be enabled or disabled on a class-by-class basis.
  B - 
Conditional compilation is used to allow tested classes to run at full speed.
  C - 
Assertions are appropriate for checking the validity of arguments in a method.
  D - 
The programmer can choose to execute a return statement or to throw an exception if an assertion fails.
9-
Which statement is true about assertions in the Java programming language?
  A - 
Assertion expressions should not contain side effects.
  B - 
Assertion expression values can be any primitive type.
  C - 
Assertions should be used for enforcing preconditions on public methods.
  D - 
An AssertionError thrown as a result of a failed assertion should always be handled by the enclosing method.
10-
Which of the following statements is true?
  A - 
It is proper to handle assertion statement failures using a catch (AssertionException ae) block.
  B - 
It is sometimes good practice to throw an AssertionError explicitly.
  C - 
If an AssertionError is thrown in a try-catch block, the finally block will be bypassed.
  D - 
Private getter() and setter() methods should not use assertions to verify arguments.
 
[Người đăng: Thành Lãm - ST]
Ghé thăm Kênh của Vị Sư "hai lần chết đi sống lại"
Tu Si Chau Soc Thon

https://www.youtube.com/channel/UCoyC9WTTVR-M3qpTKKEXGnQ

Chau Soc Thon Official Channel


Phong Bảo Official
Phong Bao Official
Xem Nhiều nhất
Trắc Nghiệm Pascal - Bài 20
Trắc Nghiệm ASP.NET - Bài 12
Trắc Nghiệm Ngôn Ngữ Lập Trình C - Bài 16
Trắc Nghiệm ASP.NET - Bài 01
Trắc Nghiệm ASP.NET - Bài 03
Trắc nghiệm C++ - Bài 18
Trắc Nghiệm C# - Bài 53
Trắc Nghiệm ASP.NET - Bài 02
Trắc Nghiệm C# - Bài 42
Trắc Nghiệm Java - Bài 01
Trắc Nghiệm ASP.NET - Bài 04
Trắc Nghiệm Pascal - Bài 22
Trắc Nghiệm ASP.NET - Bài 13
Trắc Nghiệm ASP.NET - Bài 09
Trắc Nghiệm ASP.NET - Bài 08
Trắc nghiệm PHP - Bài 01
Trắc Nghiệm ASP.NET - Bài 06
Trắc Nghiệm ASP.NET - Bài 11
Trắc Nghiệm ASP.NET - Bài 05
Trắc Nghiệm ASP.NET - Bài 23
Đề Xuất
Trắc Nghiệm Thiết Kế Web Và Flash - Bài 10
Trắc Nghiệm Java - Bài 12
Trắc Nghiệm Pascal - Bài 06
Trắc Nghiệm Thiết Kế Web Và Flash - Bài 05
Trắc nghiệm Linux ( English ) - Bài 29
Trắc Nghiệm C# - Bài 39
Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 61
Trắc Nghiệm Thiết Kế Web - Bài 14
Trắc Nghiệm Pascal - Bài 22
Trắc Nghiệm Visual Basic - Bài 38
Trắc nghiệm Ngôn Ngữ Lập Trình C++ - Bài 17
Trắc Nghiệm Java - Bài 26
Trắc Nghiệm Thiết Kế Web Và Flash - Bài 06
Trắc nghiệm Linux ( English ) - Bài 25
Trắc nghiệm Linux - Bài 67
Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 87
Trắc nghiệm Linux - Bài 58
Trắc nghiệm Linux - Bài 42
Trắc Nghiệm Thiết Kế Web (English) - Bài 28
Trắc Nghiệm Thiết Kế Web Và Flash - Bài 26
Phát triển hệ thống: TRƯƠNG HỮU ĐỨC - Phiên bản 3.0 - © Copyright 2013 - 2024 - VNEDU.ORG

free counters