Question 1: What will be the value of text3 when the following code is executed?
String text1 = "a" + "b";
String text2 = "c";
String text3 = text1 + text2 + text1;
Select one:
a. abca
b. abc
c. ababc
d. abcab
Solution: abcab
Question 2: An Object can be defined as an instance of a ___________.
Select one:
a. state
b. class
c. attribute
d. group
Solution: class
Question 3: Which of the following class's object do you need in order to perform input operation in Java?
Select one:
a. Scanner
b. Date
c. JFrame
d. String
Solution: Scanner
Question 4: Which of the following is a valid declaration and creation of an object of class Box?
Select one:
a. Box obj = new Box;
b. new Box obj;
c. Box obj = new Box();
d. obj = new Box();
Solution: Box obj = new Box();
Question 5: Identify from the below the states and the behaviours of a dog:
barking
breed
eating
color
name
wagging the tail
Solution: Barking = behavior
Breed= state
Eating = behaviour
Color = state
Name = state
Wagging the tail = behavior
Question 6: Which of these operators is used to allocate memory for an object in Java?
Select one:
a. alloc
b. malloc
c. give
d. new
Solution: new
Question 7: This code will compile and when run will print out "Hello world"
public class Main{
public static void main(String args){
System.out.println("Hello world");
}
}
Select one:
a. True
b. False
Solution: True
Question 8: What will be the output of the following Java program?
Select one:
a. I have a quiz today. I hope I can score good grade.
b. I have a quiz today.
c. I hope I can score good grade.
d. I have a quiz today.
e. I have a quiz today.I hope I can score good grade.
Solution: I have a quiz today. I hope I can score good grade.
Question 9: Study the following codes:
In which line of the codes, the object is created? (Give the line number)
What is the type/class name of the object used in the program?
setModel is an example of _____________.
What is the name of the class?
What will be displayed by the statement in line 18?
What will be displayed by the statement in line 17?
What is the name of the object used in the program?
Solution: In which line of the codes, the object is created? (Give the line number) = 10
What is the type/class name of the object used in the program? = Car
setModel is an example of _____________. = method
What will be displayed by the statement in line 18? = 2017
What will be displayed by the statement in line 17? = Jazz
What is the name of the object used in the program? = car1
Question 10: Any entity that has _________ and _________ is known as an object. For example, a chair, pen, table, keyboard, bike, etc. and it can be physical or logical.
Select one:
a. method behaviour
b. state behaviour
c. name age
d. state property
Solution: state behaviour
Question 11: Which of the following is/are incorrectly import the Scanner class into your program:
Select one or more:
a. import java.util;
b. import java.util.Scanner;
c. import java.util.*;
d. import javax.swing.Scanner;
Solution: import java.util;
import javax.swing.Scanner;
Question 12: What will be the displayed when the following code is executed?
System.out.println("Venue is " + 18 / 2);
Select one:
Venue is 18/2
Venue is 9.0
Venue is 182
Venue is 9
Solution: Venue is 9
Question 13: Which of these keywords is used to make a class?
Select one:
a. class
b. struct
c. static
d. public
Solution: class
No comments:
Post a Comment