Font size
WorksheetsTrắc nghiệm kiến thức Java Core - Phần I
Total questions: 15
Worksheet time: 9mins
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.
jump
break
change
continue
All ___________ in a class must be placed after the package statement and before the class declaration.
class members
Access specifiers
Method modifiers
Import statements
__________ inside methods are not given any access specifiers.
Class
Global variables
Instance variables
Local variables
When methods with the same name but different parameters are defined in the same class, then the process is known as ______________
Method clogging
Method overloading
Method overriding
Method recursing
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.
Statements 1, 2 are true
Statements 3, 4 are true
Statements 1, 3 are true
Statements 2, 4 are true
____________ literals are enclosed in single quotes.
String
Character
Floating point
Integer
____________ consists of sequence of characters enclosed in double quotes.
Character literals
Null literals
Numeric literals
String literals
In Java, _____________ data type is an address of an object or an array created in memory
primitive
reference
format
int
The extension of a java source file is .... ?
.javac
.java
.bytecode
.class
Select valid variable name in java ?
int
myvar1
static
%test
Thứ tự nào sau đây là đúng trong một file mã nguồn Java ?
Khai báo package
Các lệnh import
Định nghĩa lớp
Các lệnh import
Khai báo package
Định nghĩa lớp
Định nghĩa lớp
Các lệnh import
Khai báo package
Khai báo package
Định nghĩa lớp
Các lệnh import
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)
instance static block local
instance block local static
local instance static block
static instance local block
instance block static local
Chọn ra hai cách tạo mảng hợp lệ
int[] a = new int[];
int[] a = new int[20];
int a = new int[10];
int a = new [10];
int[] a = {1, 2, 3};
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);
Lỗi dịch chương trình
In ra “Not equal 10”
In ra “We are equal 10”
In ra “Not equal 20”
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à:
X
Y
Z
Lỗi biên dịch
Lỗi khi chạy chương trình
