wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Trắc nghiệm kiến thức Java Core - Phần I

Total questions: 15

Worksheet time: 9mins

Name
Class
Date
1.

Java provides some statements that will change the flow of control based on conditions. __________ statement stops the execution of the innermost loop in the program and starts processing the next line of code after the block.

a)

jump

b)

break

c)

change

d)

continue

2.

All ___________ in a class must be placed after the package statement and before the class declaration.

a)

class members

b)

Access specifiers

c)

Method modifiers

d)

Import statements

3.

__________ inside methods are not given any access specifiers.

a)

Class

b)

Global variables

c)

Instance variables

d)

Local variables

4.

When methods with the same name but different parameters are defined in the same class, then the process is known as ______________

a)

Method clogging

b)

Method overloading

c)

Method overriding

d)

Method recursing

5.

1. Primitive variables are used to store primitive data type values.
2. Primitive instance variables are accessible throughout the class in which they have declared.
3. Primitive local variables are declared outside the methods and their scope is global.
4. Primitive variables are used to store reference to objects.

a)

Statements 1, 2 are true

b)

Statements 3, 4 are true

c)

Statements 1, 3 are true

d)

Statements 2, 4 are true

6.

____________ literals are enclosed in single quotes.

a)

String

b)

Character

c)

Floating point

d)

Integer

7.

____________ consists of sequence of characters enclosed in double quotes.

a)

Character literals

b)

Null literals

c)

Numeric literals

d)

String literals

8.

In Java, _____________ data type is an address of an object or an array created in memory

a)

primitive

b)

reference

c)

format

d)

int

9.

The extension of a java source file is .... ?

a)

.javac

b)

.java

c)

.bytecode

d)

.class

10.

Select valid variable name in java ?

a)

int

b)

myvar1

c)

static

d)

%test

11.

Thứ tự nào sau đây là đúng trong một file mã nguồn Java ?

a)

Khai báo package

      Các lệnh import

      Định nghĩa lớp

b)

Các lệnh import

      Khai báo package    

      Định nghĩa lớp

c)

Định nghĩa lớp

      Các lệnh import

      Khai báo package    

d)

Khai báo package    

      Định nghĩa lớp

      Các lệnh import

12.

Các cách sắp xếp nào là đúng đối với các loại biến trong java ? (Theo thứ tự giảm dần của phạm vi biến)

a)

instance static block local

b)

instance block local static

c)

local instance static block

d)

static instance local block

e)

instance block static local

13.

Chọn ra hai cách tạo mảng hợp lệ

a)

int[] a = new int[];

b)

int[] a = new int[20];

c)

int a = new int[10];

d)

int a = new [10];

e)

int[] a = {1, 2, 3};

14.

Kết quả khi thực hiện đoạn mã sau là gì ?

int output = 10;

boolean b1 = false;

if ((b1==true)&&((output+=10)==20))

          System.out.println(“We are equal “ + output);

else

           System.out.println(“Not equal “ + output);

a)

Lỗi dịch chương trình

b)

In ra “Not equal 10”

c)

In ra “We are equal 10”

d)

In ra “Not equal 20”

15.

Cho đoạn mã sau :

class X {

          public String mark() { return “X”; }     

}

class Y extends X {

          public String mark(){ return “Y”; }

}

class Z extends Y {

          public String mark(){ return “Z”; }

}

class A extends Z {

          public static void main(String[] args){

                    System.out.println(new A().mark());

}

}

Kết quả khi chạy đoạn chương trình trên là:

a)

X

b)

Y

c)

Z

d)

Lỗi biên dịch

e)

Lỗi khi chạy chương trình