Multiple Choice ICS2606

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

45 Terms

1
New cards

 Which of the following is a valid way to create an array in Java?


1. int[] arr = new int[5];  

2. array int arr = new int[5];  

3. int arr = new int[5];  

4. int arr[] = 5;  


*Answer:* 1. int[] arr = new int[5];

2
New cards

 What is the default value of a boolean variable in Java?


 false  

2. true  

3. undefined  


Answer: 1. false  


3
New cards

 What is the result of the expression: 10 % 3?


1. 10  

2. 1  

3. 0  

4. 3  


Answer: 2. 1  


4
New cards

4. Which of the following is a benefit of using inheritance?

1. Increased complexity  

2. More memory usage  

3. Slower execution  

4. Code reusability  


*Answer:* 4. Code reusability

5
New cards

5. All variables in Java must be declared before they can be used.


1. TRUE  

2. FALSE  


Answer: 1. TRUE  


6
New cards

What is the data type of the variable "name" if it is declared as follows: name = "John";?

1. double  

2. int  

3. String  

4. char  


Answer: 3. String  


7
New cards

What is polymorphism in object-oriented programming?


1. Ability to create multiple classes  

2. Ability to encapsulate data  

3. Ability to inherit properties  

4. Ability to take many forms  


Answer: 4. Ability to take many forms  


8
New cards

9. The value of a variable can be changed after it has been declared.


1. TRUE  

2. FALSE  


Answer: 1. TRUE  


9
New cards

What is a variable in Java?


1. A data type  

2. A container to store data  

3. To create methods  

4. A method of outputting data  


*Answer:* 2. A container to store data

10
New cards

 Which of the following methods can be used to find the length of a one-dimensional array in Java?


1. arr.length()  

2. arr.length  

3. length(arr)  

4. size(arr)  


Answer: 2. arr.length  


11
New cards

Program tasks are listed inside the main() method in Java.


1. FALSE  

2. TRUE  


Answer: 2. TRUE  


12
New cards

In Java, which keyword is used to refer to the parent class in a subclass?


1. parent  

2. super  

3. this  

4. base  


*Answer:* 2. super 

13
New cards

What is the output of the following code: System.out.println(5 + 3)?


1. 5  

2. 53  

3. 8  

4. Error  


*Answer:* 3. 8 

14
New cards

 Which of the following is the correct way to declare a method in Java?


1. methodName void()  

2. void methodName()  

3. void methodName()  

4. method voidName()  


Answer: 2. void methodName()  


15
New cards

 What is the syntax for declaring a variable in Java?


1. type variableName;  

2. variableName = value;  

3. value = variableName;  

4. type variableName = value;  


Answer: 1. type variableName;  


---


16
New cards

How do you access the third element of an array named 'arr' in Java?


1. arr(3)  

2. arr(2)  

3. arr[3]  

4. arr[2]  


Answer: 4. arr[2]  


17
New cards

. Which of the following keywords is used to create a new class in Java

1. create  

2. new  

3. define  

4. class  


Answer: 4. class  


18
New cards


### 19. Which of the following is an example of compile-time polymorphism?


1. Interface Implementation  

2. Method Overloading  

3. Abstract Classes  

4. Method Overriding  


Answer: 2. Method Overloading  


19
New cards

 What is the primary purpose of inheritance in object-oriented programming?


1. To declare variables  

2. To create a new class from an existing class  

3. To implement interfaces  

4. To define a method  


*Answer:* 2. To create a new class from an existing class

20
New cards

 21. What is the purpose of the 'enum' keyword in Java?


1. Implement an interface  

2. To create a new class  

3. To define a set of named constants  

4. To declare a variable  


Answer: 3. To define a set of named constants  


21
New cards

22. Which of the following is a valid way to declare a constant in Java?


1. final int x = 10;  

2. const int x = 10;  

3. int x = 10;  

4. static int x = 10;  


Answer: 1. final int x = 10;  


22
New cards

 What is the purpose of the 'static' keyword in Java

1. To create an instance of a class  

2. To create a constant variable  

3. To define a method that belongs to the class rather than instances  

4. To indicate a variable is private  


Answer: 3. To define a method that belongs to the class rather than instances  


23
New cards

24. In which programming language is polymorphism commonly implemented through interfaces?


1. C++  

2. Java  

3. Python  

4. JavaScript  


Answer: 2. Java  


24
New cards


### 25. What is the main advantage of using polymorphism in object-oriented programming?


1. To restrict access to class members  

2. To allow methods to be defined in multiple ways  

3. To improve memory usage  

4. To increase the complexity of the code  


Answer: 2. To allow methods to be defined in multiple ways  


25
New cards

 26. Which of the following keywords is used to inherit a class in Java?


1. extends  

2. super  

3. implements  


Answer: 1. extends  


26
New cards

27. Can an enum in Java implement interfaces?


1. TRUE  

2. FALSE  


Answer: 1. TRUE  


27
New cards

 28. The System.out.println() method is used to print output to the console in Java.


1. FALSE  

2. TRUE  


Answer: 2. TRUE  


28
New cards
29
New cards
30
New cards
31
New cards
32
New cards
33
New cards
34
New cards
35
New cards
36
New cards
37
New cards
38
New cards
39
New cards
40
New cards
41
New cards
42
New cards
43
New cards
44
New cards
45
New cards