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 51
Ngày làm bài: Hôm nay lúc 08:11:46 (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-
What will be the output of the program?
public abstract class AbstractTest 
{
    public int getNum() 
    {
        return 45;
    }
    public abstract class Bar 
    {
        public int getNum() 
        {
            return 38;
        }
    }
    public static void main (String [] args) 
    {
        AbstractTest t = new AbstractTest() 
        {
            public int getNum() 
            {
                return 22;
            }
        };
        AbstractTest.Bar f = t.new Bar() 
        {
            public int getNum() 
            {
                return 57;
            }
        };
        
        System.out.println(f.getNum() + " " + t.getNum());
    }
}

  A - 
57 22
  B - 
45 38
  C - 
45 57
  D - 
An exception occurs at runtime.
2-
What will be the output of the program?
public class Q126 implements Runnable 
{ 
    private int x; 
    private int y; 

    public static void main(String [] args) 
    { 
        Q126 that = new Q126(); 
        (new Thread(that)).start( ); /* Line 8 */
        (new Thread(that)).start( ); /* Line 9 */
    } 
    public synchronized void run( ) /* Line 11 */
    { 
        for (;;) /* Line 13 */
        { 
            x++; 
            y++; 
            System.out.println("x = " + x + "y = " + y); 
        } 
    } 
}

  A - 
An error at line 11 causes compilation to fail
  B - 
Errors at lines 8 and 9 cause compilation to fail.
  C - 
The program prints pairs of values for x and y that might not always be the same on the same line (for example, "x=2, y=1")
  D - 
The program prints pairs of values for x and y that are always the same on the same line (for example, "x=1, y=1". In addition, each value appears once (for example, "x=1, y=1" followed by "x=2, y=2")
3-
What will be the output of the program?
class MyThread extends Thread 
{
    public static void main(String [] args) 
    {
        MyThread t = new MyThread(); /* Line 5 */
        t.run();  /* Line 6 */
    }

    public void run() 
    {
        for(int i=1; i < 3; ++i) 
        {
            System.out.print(i + "..");
        }
    }
}

  A - 
This code will not compile due to line 5.
  B - 
This code will not compile due to line 6.
  C - 
1..2..
  D - 
1..2..3..
4-
What will be the output of the program?
public class ThreadTest extends Thread 
{ 
    public void run() 
    { 
        System.out.println("In run"); 
        yield(); 
        System.out.println("Leaving run"); 
    } 
    public static void main(String []argv) 
    { 
        (new ThreadTest()).start(); 
    } 
}

  A - 
The code fails to compile in the main() method
  B - 
The code fails to compile in the run() method
  C - 
Only the text "In run" will be displayed
  D - 
The text "In run" followed by "Leaving run" will be displayed
5-
What will be the output of the program?
public class Test107 implements Runnable 
{ 
    private int x; 
    private int y; 

    public static void main(String args[]) 
    {
        Test107 that = new Test107(); 
        (new Thread(that)).start(); 
        (new Thread(that)).start(); 
    } 
    public synchronized void run() 
    {
        for(int i = 0; i < 10; i++) 
        { 
            x++; 
            y++; 
            System.out.println("x = " + x + ", y = " + y); /* Line 17 */
        } 
    } 
} 

  A - 
Compilation error.
  B - 
Will print in this order: x = 1 y = 1 x = 2 y = 2 x = 3 y = 3 x = 4 y = 4 x = 5 y = 5... but the output will be produced by both threads running simultaneously.
  C - 
Will print in this order: x = 1 y = 1 x = 2 y = 2 x = 3 y = 3 x = 4 y = 4 x = 5 y = 5... but the output will be produced by first one thread then the other. This is guaranteed by the synchronised code.
  D - 
Will print in this order x = 1 y = 2 x = 3 y = 4 x = 5 y = 6 x = 7 y = 8...
6-
What allows the programmer to destroy an object x?
  A - 
x.delete()
  B - 
x.finalize()
  C - 
Runtime.getRuntime().gc()
  D - 
Only the garbage collection system can destroy an object.
7-
Which of the following statements is true?
  A - 
It is sometimes good practice to throw an AssertionError explicitly.
  B - 
Private getter() and setter() methods should not use assertions to verify arguments.
  C - 
If an AssertionError is thrown in a try-catch block, the finally block will be bypassed.
  D - 
It is proper to handle assertion statement failures using a catch (AssertionException ae) block.
8-
What will be the output of the program?
public class WrapTest 
{
    public static void main(String [] args) 
    {
        int result = 0;
        short s = 42;
        Long x = new Long("42");
        Long y = new Long(42);
        Short z = new Short("42");
        Short x2 = new Short(s);
        Integer y2 = new Integer("42");
        Integer z2 = new Integer(42);

        if (x == y) /* Line 13 */
            result = 1;
        if (x.equals(y) ) /* Line 15 */
            result = result + 10;
        if (x.equals(z) ) /* Line 17 */
            result = result + 100;
        if (x.equals(x2) ) /* Line 19 */
            result = result + 1000;
        if (x.equals(z2) ) /* Line 21 */
            result = result + 10000;

        System.out.println("result = " + result);
    }
}

  A - 
result = 1
  B - 
result = 10
  C - 
result = 11
  D - 
result = 11010
9-
What will be the output of the program?
class Q207 
{ 
    public static void main(String[] args) 
    {
        int i1 = 5; 
        int i2 = 6; 
        String s1 = "7"; 
        System.out.println(i1 + i2 + s1); /* Line 8 */
    } 
}

  A - 
18
  B - 
117
  C - 
567
  D - 
Compiler error
10-
What will be the output of the program?
public class StringRef 
{
    public static void main(String [] args) 
    {
        String s1 = "abc";
        String s2 = "def";
        String s3 = s2;   /* Line 7 */
        s2 = "ghi";
        System.out.println(s1 + s2 + s3);
    }
}

  A - 
abcdefghi
  B - 
abcdefdef
  C - 
abcghidef
  D - 
abcghighi
 
[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 - Bài 18
Trắc Nghiệm C# - Bài 34
Trắc Nghiệm C Sharp - Bài 09
Trắc Nghiệm Thiết Kế Web Và Flash - Bài 13
Trắc Nghiệm Visual Foxpro - Bài 02
Trắc Nghiệm Java - Bài 42
Trắc Nghiệm Thiết Kế Web (English) - Bài 29
Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 87
Trắc Nghiệm ASP.NET (English) - Bài 28
Trắc Nghiệm C Sharp - Bài 30
Trắc nghiệm Linux - Bài 53
Trắc nghiệm Ngôn Ngữ Lập Trình C++ - Bài 57
Trắc nghiệm Ngôn Ngữ Lập Trình C++ - Bài 52
Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 37
Trắc nghiệm Linux - Bài 64
Trắc Nghiệm ASP.NET - Bài 19
Trắc Nghiệm Visual Basic - Bài 29
Trắc Nghiệm Ngôn Ngữ Lập Trình C - Bài 06
Trắc Nghiệm Thiết Kế Web Và Flash - Bài 09
Trắc Nghiệm Visual Basic - Bài 40
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