GMT: Chủ Nhật, ngày 29  tháng 3, năm 2020 . .   
Đăng nhập tạm thời:  

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   
 C#     C++     Visual Basic     Visual Foxpro     C     Java     Pascal     Thiết Kế Web     ASP.NET     XML     CSS     PHP   

Trắc Nghiệm Java - Bài 39
What will be the output of the program? try { int x = 0; int y = 5 / x; } catch (Exception e) { System.out.println("Exception"); } catch (ArithmeticException ae) { System.out.println(" Arithmetic Exception"); } System.out.println("finished"); A. finished B. Exception C. Compilation fails. D. Arithmetic Exception...........
Thời gian bắt đầu: Hôm nay lúc 15:14:14(Server time)
Số câu hỏi: 10.   Tổng điểm: 10
Thời gian làm bài: 20 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?
try 
{ 
    int x = 0; 
    int y = 5 / x; 
} 
catch (Exception e) 
{
    System.out.println("Exception"); 
} 
catch (ArithmeticException ae) 
{
    System.out.println(" Arithmetic Exception"); 
} 
System.out.println("finished");
A-
Finished
B-
Exception
C-
Compilation fails.
D-
Arithmetic Exception
2-
Which statement is true?
A-
A try statement must have at least one corresponding catch block.
B-
Multiple catch statements can catch the same class of exception more than once.
C-
An Error that might be thrown in a method must be declared as thrown by that method, or be handled within that method.
D-
Except in case of VM shutdown, if a try block starts to execute, a corresponding finally block will always start to execute.
3-
class Test1 
{
    public int value;
    public int hashCode() { return 42; }
}
class Test2 
{
    public int value;
    public int hashcode() { return (int)(value^5); }
}
which statement is true?
A-
class Test1 will not compile.
B-
The Test1 hashCode() method is more efficient than the Test2 hashCode() method.
C-
The Test1 hashCode() method is less efficient than the Test2 hashCode() method.
D-
class Test2 will not compile.
4-
What will be the output of the program?
public class Foo 
{
    Foo() 
    {
        System.out.print("foo");
    }
    
class Bar
{
    Bar() 
    {
        System.out.print("bar");
    }
    public void go() 
    {
        System.out.print("hi");
    }
} /* class Bar ends */

    public static void main (String [] args) 
    {
        Foo f = new Foo();
        f.makeBar();
    }
    void makeBar() 
    {
        (new Bar() {}).go();
    }
}/* class Foo ends */
A-
Compilation fails.
B-
It prints "barhi"
C-
An error occurs at runtime.
D-
It prints "foobarhi"
5-
class Bar { } 
class Test 
{  
    Bar doBar() 
    {
        Bar b = new Bar(); /* Line 6 */
        return b; /* Line 7 */
    } 
    public static void main (String args[]) 
    { 
        Test t = new Test();  /* Line 11 */
        Bar newBar = t.doBar();  /* Line 12 */
        System.out.println("newBar"); 
        newBar = new Bar(); /* Line 14 */
        System.out.println("finishing"); /* Line 15 */
    } 
}
At what point is the Bar object, created on line 6, eligible for garbage collection?
A-
after line 12
B-
after line 14
C-
after line 7, when doBar() completes
D-
after line 15, when main() completes
6-
class Test 
{  
    private Demo d; 
    void start() 
    {  
        d = new Demo(); 
        this.takeDemo(d); /* Line 7 */
    } /* Line 8 */
    void takeDemo(Demo demo) 
    { 
        demo = null;  
        demo = new Demo(); 
    } 
}
When is the Demo object eligible for garbage collection?
A-
After line 7
B-
After line 8
C-
After the start() method completes
D-
When the instance running this code is made eligible for garbage collection.
7-
public class X 
{
    public static void main(String [] args) 
    {
        X x = new X();
        X x2 = m1(x); /* Line 6 */
        X x4 = new X();
        x2 = x4; /* Line 8 */
        doComplexStuff();
    }
    static X m1(X mx) 
    {
        mx = new X();
        return mx;
    }
}
After line 8 runs. how many objects are eligible for garbage collection?
A-
0
B-
1
C-
2
D-
3
8-
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
9-
What will be the output of the program?
public class SqrtExample 
{
    public static void main(String [] args) 
    {
        double value = -9.0;
        System.out.println( Math.sqrt(value));
    }
}
A-
3.0
B-
-3.0
C-
NaN
D-
Compilation fails.
10-
What will be the output of the program?
String a = "newspaper";
a = a.substring(5,7);
char b = a.charAt(1);
a = a + b;
System.out.println(a);
A-
apa
B-
app
C-
apea
D-
apep
[ Thành Lãm - ST ]

Chia sẻ trên Facebook   Google Boomarks   Google Buzz    Xem: 1151. Đăng: 23-07-2012.   

Support Link:
Thông tin trang Web. Online since: 2011.
Disclaimer of Liability and Endorsement:
free counters
VNEDU.ORG IS A NON-PROFIT WEBSITE! All contents throughout this website are from Internet and other sources and are posted by users, copyright belongs to its original author. VNEDU.ORG stores for educational purpose only. VNEDU.ORG resumes no responsibility and liability, make no promise, or guarantee for the accuracy or efficiency of any content. If you find any content that is in violation of copyright laws, please notify us and we will immediately remove them. Thank you for visiting VNEDU.ORG