C# - C Sharp: PRO192 - PT1


Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên

(nhấn nút 'Result' để biết kết quả)

Q1: Which keyword is used to declare a constant variable in Java?
const
final
static
immutable

Q2: Which keyword is used to check multiple conditions?
when
switch
for
match

Q3: What is the output?
 int i = 1;
 while (i < 3) {
    System.out.print(i);
    i++;
 }
12
123
1
3

Q4: How do you declare an array in Java?
int arr = new int(5);
int[] arr = new int[5];
int arr[5];
array int arr;

Q5: Arrays in Java are:
Primitive types
Objects
Constants
Variables

Q6: What will happen if you access an array element out of its bounds?
Compile error
Runtime error (ArrayIndexOutOfBoundsException)
Prints null
Wraps around

Q7: How do you find the length of an array arr?
arr.size()
arr.length
arr.length()
arr.size

Q8: What is method overloading?
Same method name, different parameters
Same name, same parameters
Different names, same parameters
Using methods inside loops

Q9: Which of these methods can access instance variables directly?
A. Static method
B. Instance method
C. All of the above
D. None of the above

Q10: How do you create an object of class Car?
Car();
Car c = new Car();
Car c();
Create Car;

Q11: Which access modifier makes a class visible only in the same package?
private
protected
publick
default (no modifier)

Q12: What does the keyword this refer to?
Current class name
Current object
Parent class
Static variable

Q13: What is encapsulation in Java?
Hiding internal details of an object
Inheriting from another class
Overriding methods
None of the above

Q14: What is a blueprint for creating objects?
Object
Method
Class
Constructor

Q15: What is a constructor in Java?
A method with same name as class
A static method
A return-type function
None of the above

Q16: Which of the following statements is true about constructors?
They must have a return type
They can be overloaded
They can be called explicitly only
They are static

Q17: When is a constructor called?
When an object is created
When a class is loaded
When a method is called
At compile time

Q18: Which keyword is used to call a parent class constructor?
parent()
base()
super()
this()

Q19: What happens if you don’t define a constructor in a class?
Compile-time error
Default constructor is provided by compiler
The class cannot be instantiated
JVM crashes

Q20: What is the main purpose of getter methods?
Set a variable’s value
Retrieve a variable’s value
Create a new object
Initialize constructors

Q21: What is the naming convention for getters?
fetchVariable()
getVariable()
returnVariable()
giveVariable()

Q22: What is the main purpose of setter methods?
Change the value of private fields
Display data
Return values
Delete variables

Q23: Which of the following is true about setter methods?
They usually start with "set"
They take a parameter
They have a void return type
All of the above

Q24: Why are getters and setters used in Java?
To follow encapsulation principle
To make variables public
To improve speed
To reduce memory

Q25: What will happen if a subclass defines a method already defined in its superclass?
Compilation error
The superclass method is hidden
The subclass method overrides the superclass method
Both methods are executed

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)
» Tiếp: Bài làm mẫu 1
« Trước: Quiz
Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên
Copied !!!