0% found this document useful (0 votes)
71 views25 pages

HASIL QUIZ ORACLE SECTION 1-8 - Tantri

The document contains the results of a quiz on Oracle Section 1-8. It includes 15 multiple choice questions on topics like whitespace, comments, breakpoints, methods, classes, objects, and more. The correct answers are indicated with an asterisk. Overall, the quiz assessed fundamental Java concepts taught in sections 1 through 8 of an Oracle course.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views25 pages

HASIL QUIZ ORACLE SECTION 1-8 - Tantri

The document contains the results of a quiz on Oracle Section 1-8. It includes 15 multiple choice questions on topics like whitespace, comments, breakpoints, methods, classes, objects, and more. The correct answers are indicated with an asterisk. Overall, the quiz assessed fundamental Java concepts taught in sections 1 through 8 of an Oracle course.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

HASIL QUIZ ORACLE SECTION 1-8

Section 2 Quiz
(Answer all questions in this section)
1. Which of the following 2 statements are true about whitespace?
(Choose all correct answers)
Whitespace reduces the performance of the program.
Whitespace eliminates typing mistakes while programming.
Whitespace helps to keep your code organized. (*)
Whitespace increases execution time of your program.
Whitespace makes your code more readable. (*)
Correct
(1/1) Points
2. Which two are the correct syntax for adding comments?
(Choose all correct answers)
Start with a slash-star (/*). End with a star-slash (*/). (*)
Start with two slashes (//). End with two slashes (//).
Start with two slashes (//). End when the line ends. (*)
Start with two slashes and a star (//*). End with a star-slash (*/).
Start with a slash- star (/*). End with slash-star (/*).
Correct
(1/1) Points
3. A Java program can be written in the single line.
True (*)
False
Correct
(1/1) Points
4. A breakpoint can be set by clicking a number in the left margin of the IDE.
Clicking again removes the breakpoint.
True (*)
False
Correct
(1/1) Points
5. Code within curly braces is called a “Block of code”.
True (*)
False
Correct
6. You can set any number of breakpoints for your program.
True (*)
False
Correct
(1/1) Points
7. In the code example below, identify any methods:

public class Employee {


public String name = " Duke";
public int empId = 12105;
public float salary;

public void displaySalary(){


System.out.println("Employee Salary: "+salary);
}
}
name
salary
displaySalary() (*)
empId
Correct
(1/1) Points
8. You design a Circle class with various fields and methods. Which of the following
could be fields in this class? Distinguish which of these are between the properties
and behavior.
(Choose all correct answers)
calculateCircumference()
color (*)
calculateArea()
calculateDiameter()
radius (*)
Correct
(1/1) Points
9. In object oriented programming, there is an emphasis on which of the following
two:
(Choose all correct answers)
Writing algorithms.
Creation of procedures.
Object interaction without a prescribed order. (*)
Modeling objects. (*)
Correct
(1/1) Points
10. You have a beautiful garden at home. On Sunday, you start budding your rose
plant to make few more samples of rose plants to plant in the garden. Can you
categorize how this scenario could be represented by classes and instances?
Samples of the rose plant are called classes and not the actual rose plant.
Samples are the class and the rose plant is the instances of samples.
Rose plant is the object and samples are not instances of the plant because they
have not grown yet.
Rose plant is the class and the samples generated from the rose plant are instances
of that class. (*)
Correct
11. In object oriented programming, an object comprises of properties and
behaviors where properties represented as fields of the object and behavior is
represented as method.
True (*)
False
Correct
(1/1) Points
12. During the Testing phase of software development, which of the following are
the tasks undertaken by the programmer?
(Choose all correct answers)
Finding the bugs. (*)
Planning the order to implement features.
Fixing the bugs. (*)
Listing required features.
Correct
(1/1) Points
13. A software feature may allow the user to perform a specific task.
True (*)
False
Correct
(1/1) Points
14. If the requirement step of the Spiral Model of development is forgotten, which
of the following could occur?
Code becomes messy.
Required software features are missing from the program. (*)
Solutions seem elusive.
The Program gives inaccurate results.
Correct
(1/1) Points
15. What is the correct order of steps in the Spiral Model of Development?
Design, Requirements, Develop, Test
Requirements, Design, Test, Develop
Design, Develop , Requirements, Test
Requirements, Design, Develop, Test (*)
Correct
Section 3 Quiz 2 - L3-L5
(Answer all questions in this section)
1. char is the primitive textual data type in Java.
True (*)
False
Correct
(1/1) Points
2. The print() method prints to the console and automatically creates a line.
True
False (*)
Correct
(1/1) Points
3. Char data types cannot handle multiple characters.
True (*)
False
Correct
(1/1) Points
4. Which two statements are true about String concatenation.
(Choose all correct answers)
String concatenation can be done with String variables and String Literals. (*)
Strings can be combined using the ‘+’ operator (*)
String concatenation cannot be done with numbers.
String concatenation cannot be done with more than two String Literals.
Correct
(1/1) Points
5. A character preceded by backslash is called an escape sequence.
True (*)
False
Correct
6. Given the expression:

String message = "Hello World";

Which is the String Literal?


message
String message
Hello World (*)
String message = "Hello World";
Correct
(1/1) Points
7. Which exception occurs because a String cannot be parsed as an int?
NumberFormatException (*)
ArithmeticException
NullPointerException
ValueNotFoundException
Correct
(1/1) Points
8. Which is a valid way to parse a String as an int?
int intVar1 = Integer.parseInt("100"); (*)
int intVar1 = Integer.parseInt("One Hundred");
int intVar1 = "100";
nt intVar1 = (int)"100";
Correct
(1/1) Points
9. Which two statements are true about type casting?
(Choose all correct answers)
Type casting retains the size of the value or the original data type.
Type casting changes the type of the value stored. (*)
Type casting lowers the range of possible values. (*)
Type casting cannot be performed on equations.
Correct
(1/1) Points
10. Which two statements are correct about the usage of an underscore?
(Choose all correct answers)
Underscores help the compiler interpret large numbers.
Underscores change the value of the number.
Underscores help make large numbers more readable. (*)
Underscores do not affect the value of the variable. (*)
Correct
11. When the result of an expression is assigned to a temporary memory location,
what is the size of memory allocated?
The size of the any data type used in the expression.
The size of the largest data type used in the expression. (*)
The size of the smallest data type used in the expression.
A default size is allocated.
Correct
(1/1) Points
12. What is the correct way to cast a long to an int?
int longToInt = int 20L;
int longToInt = 20L(int);
int longToInt = (int)20L; (*)
int longToInt = 20L;
Correct
(1/1) Points
13. These two code fragments perform the same task.
// Fragment 1
String inputString = JOptionPane.showInputDialog("??");
int input = Integer.parseInt(inputString);
input++;

// Fragment 2
int input = Integer.parseInt(JOptionPane.showInputDialog("??")) + 1;
True (*)
False
Correct
(1/1) Points
14. You write a statement that assigns a value to a String variable as shown below.

String input = "This is Java Program";

This way of assigning values to variables is known as hard-coding.


True (*)
False
Correct
(1/1) Points
15. It's best-practice to close the Scanner stream when finished
True (*)
False
Correct
(1/1) Points

Section 4 Quiz 2 - L3-L5


(Answer all questions in this section)
1. You need to generate random integer values between 0 and 80 (inclusive). Which
statement should you use?
nextInt(81); (*)
nextInt();
nextInt(0-79);
nextInt(80);
Correct
(1/1) Points
2. Which values are returned by the method nextBoolean();
Returns the next value.
Either a true or false. (*)
An integer value.
Nothing is returned.
Correct
(1/1) Points
3. Using the Random class requires an import statement.
True (*)
False
Correct
(1/1) Points
4. Which class is used to generate random numbers?
Integer
Double
Number
Random (*)
Correct
(1/1) Points
5. What is the approximate value of PI?
0
2.718
The value varies.
3.141 (*)
Correct
6. Every method of the Math class returns a numerical result.
True (*)
False
Correct
(1/1) Points
7. Which two are the features of the Math class?
(Choose all correct answers)
Math methods can be invoked with Strings as arguments.
Common math functions like square root are taken care of in the language. (*)
You don’t have to worry about the data type returned from a Math method.
The Math methods can be invoked without creating an instance of a Math
object. (*)
Correct
(1/1) Points
8. Which is NOT true?
Static methods must be of return void. (*)
A class can have multiple static methods.
Static methods can be invoked through an instance of a class
Static methods can be invoked through the class name.
Correct
(1/1) Points
9. String objects are immutable.
True (*)
False
Correct
(1/1) Points
10. What is the output?

public static void main(String args[]) {


String greeting = "Java World!";
String w = greeting.substring(7, 11);
System.out.println(w);
}
ld!
rld! (*)
orld!
rld
Correct
11. A String is a sequence characters.
True (*)
False
Correct
(1/1) Points
12. The indexOf() method returns the index value of a character in the string.
True (*)
False
Correct
(1/1) Points
13. The replaceFirst() method replaces only the first occurrence of matching
character pattern in a string.
True (*)
False
Correct
(1/1) Points
14. The String class must be imported using java.lang.String;
True
False (*)
Correct
(1/1) Points
15. The String concat() method concatenates only String data types.
True (*)
False
Correct
Section 5 Quiz
(Answer all questions in this section)
1. What is the output?

public static void main(String args[]) {


char ch ='c';
switch(ch) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
System.out.println("Vowels");
break;
default:
System.out.println("Consonants");
}
}
Consonants (*)
Vowels
Vowels
Compilation error
Correct
(1/1) Points
2. What is the output?

public static void main(String args[]) {


char grade ='E';
if (grade == 'A') {
System.out.println("Excellent performer");
}else if (grade == 'B') {
System.out.println("Good Performer");
}else if (grade == 'C') {
System.out.println("Average Performer");
}else {
System.out.println("Below Average Performer");
}
}
Excellent performer
Below Performer
Not a Good Performer
Below Average Performer (*)
Correct
(1/1) Points
3. A break statement causes control to transfer to the end of the switch statement.
True (*)
False
Correct
(1/1) Points
4. Which two of the following data types can be used in a switch statement?
(Choose all correct answers)
boolean
float
String (*)
int (*)
Correct
(1/1) Points
5. In a boolean expression which uses the && operator, what would make this
expression evaluate to true?

boolean x = (firstCondition && secondCondition);


If both the first condition and second condition are true (*)
If both the first condition and second condition are false
If the first condition is false, but the second condition is true
If the first condition is true, but the second condition is false
Correct
6. In the OR (||) test, if the first expression on the left hand side is true then there is
no need to evaluate the second statement.
True (*)
False
Correct
(1/1) Points
7. In the AND (&&) test, if the first expression on the left hand side is false, then
there is no need to evaluate the second statement.
True (*)
False
Correct
(1/1) Points
8. What is the result?

public static void main(String[] args) {


int point = 10;
String s = (point == 1 ? "point" : "points");
System.out.println("I scored " +point +" " +s );
}
I scored 10 points (*)
I scored 1 point 10 points
I scored 1 point
Compilation error
Correct
(1/1) Points
9. A String comparison with == compares the Strings’ locations in memory and not
the content of the String.
True (*)
False
Correct
(1/1) Points
10. The equal sign (=) is used to make an assignment, whereas the == sign merely
makes a comparison and returns a boolean.
True (*)
False
Correct
(1/1) Points
11. What is the output?

public static void main(String[] args) {


String name = "Java";
String language = "Programming";
String fullName = name + language;
boolean test = fullName.equals(name + language);
System.out.println(test);
}
False
True (*)
Java Programming
JavaProgramming
Correct
(1/1) Points
12. Which three are conditional statements?
(Choose all correct answers)
switch statement (*)
do while loop
if/else statement (*)
for loop
if statement (*)
Correct
(1/1) Points
13. Which operator is used to test if both sides of a boolean expression are equal?
=
== (*)
<=
>=
Correct
(1/1) Points
14. How should Strings be compared?
The equals() method (*)
~=
=
==
Correct
(1/1) Points
15. What is the output?

public static void main(String[] args) {


int age = 43;
if (age == 43){
System.out.print("Bob is 43 ");
}
if (age == 50){
System.out.print("Bob is 50 ");
}
}
Bob is 43 (*)
Bob is 43 Bob is 50
Bob is 50
No output
Correct
Section 6 Quiz
(Answer all questions in this section)
1. A do-while will always execute statements contained in the loop at least once.
True (*)
False
Correct
(1/1) Points
2. Which statement is NOT true about do-while loops?
Statements in the loop are executed once initially, and then the condition is
evaluated.
The number of times a do-while loop is executed is dependent upon the value of
the counter variable. (*)
Statements in the loop are executed repeatedly until the condition becomes false.

Statements in the loop are executed once until the condition becomes false.
Incorrect. Refer to Section 6 Lesson 2.
(0/1) Points
3. A post-test loop evaluates its condition at the end of the loop instead of the
beginning.
True (*)
False
Correct
(1/1) Points
4. Which of the two are pre-test loops?
(Choose all correct answers)
do-while
forEach
for (*)
while (*)
Correct
(1/1) Points
5. The while loop continually executes a block of statements while a particular
condition is false.
True
False (*)
Correct
(1/1) Points
6. What is the output?

public static void main(String[] args) {


int num = 1;
while (num >= 200){
System.out.print(num + "" "");
num = num * 5;
}
}
1 5 25 125
1 5 25 125 175
No output. (*)
5 25 125
Correct
(1/1) Points
7. The purpose of adding comments is to increase the ability to understand the
logic easily.
True (*)
False
Correct
(1/1) Points
8. A continue statement is used to skip the remaining statements in the body of a
loop and continue with the next iteration of the loop.
True (*)
False
Correct
(1/1) Points
9. The only way to exit a loop is for the loop condition to evaluate to false.
True
False (*)
Correct
(1/1) Points
10. You want to compute the sum of all the marks of a given subject. Which
approach will you choose?
Looping (*)
if/else statement
switch statement
if statement
Correct
(1/1) Points
Previous

11. The for loop provides a complicated way to iterate over a range of values.
True
False (*)
Incorrect. Refer to Section 6 Lesson 1.
(0/1) Points
12. A for loop is also called a definite loop
True (*)
False
Correct
(1/1) Points
13. Given:

for(int i = 0; i > 10; i++){ }


What type of variable is i?

Static
Member
Local (*)
Global
Incorrect. Refer to Section 6 Lesson 1.
(0/1) Points
14. In the given syntax of for loop, which part represents the header section?

for (initialization; condition; update) {


// Code statement(s) }
Code statement(s)
for (initialization; condition; update) (*)
for (initialization; condition; update) { }
for (initialization; condition; update) { Code statement(s) }
Correct
(1/1) Points
15. Which statement will produce the output: 2, 4, 6, 8, 10?
for (int i = 2; i <= 10; i += 2) {
System.out.print(i + " ");
} (*)
for (int i = 1; i < 10; i += 2) {
System.out.print(i + " ");
}
for (int i = 0; i < 10; i += 2) {
System.out.print(i + " ");
}
for (int i = 0; i < 8; i += 2) {
System.out.print(i + " ");
}
Correct
(1/1) Points
Previous

Section 7 Quiz 2 - L4-L6


(Answer all questions in this section)
1. Setters are void return type methods.
True (*)
False
Correct
(1/1) Points
2. Which two are access modifiers?
(Choose all correct answers)
public (*)
static
private (*)
final
Correct
(1/1) Points
3. What is encapsulation?
A technique for writing more than one main method.
A technique for debugging.
A technique for limiting one class’s visibility to another. (*)
A technique for including primitives within an ArrayList.
Correct
(1/1) Points
4. Which two statements are true?
(Choose all correct answers)
The purpose of a getter method is to grant other classes access to public data.
The purpose of a setter method is to modify a public field
The purpose of a setter method is to allow private data to be modified safely (*)
The purpose of a getter method is to return the value of a private field (*)
Correct
(1/1) Points
5. Which two statements are true about getter methods?
(Choose all correct answers)
You must have a setter method if you have a getter method.
Getter methods typically return void.
Getters have a public access modifier. (*)
Getters usually accept no arguments. (*)
Correct
(1/1) Points
6. Access and visibility of a class should be limited as much as possible.
True (*)
False
Correct
(1/1) Points
7. Which two statements are true?
(Choose all correct answers)
An object can access another object’s public fields. (*)
An object can access another object’s public methods. (*)
An object can access another object’s main method.
An object can access another object’s public constructor.
Correct
(1/1) Points
8. An object must be instantiated before its non-static fields and methods can be
accessed.
True (*)
False
Correct
(1/1) Points
9. Static variables of a class can be accessed, even if the class has not been
instantiated.
True (*)
False
Correct
(1/1) Points
10. The fields and methods of the Math class cannot be directly accessed as they
are static.
True
False (*)
Correct
(1/1) Points
Previous

11. Given the following code, why does your IDE complain that “non-static variable
name cannot be referenced from a static context”?

public class Employee{


public static int employeeID;
public String name;

public static void display(){


System.out.println(employeeID);
System.out.println(name);
}
}
It would be possible to call the display() method and attempt to reference an
object’s name before any object exists. (*)
Static variables cannot be referenced from methods.
Static variables are only accessible from instance methods.
The variable name has a null value.
Correct
(1/1) Points
12. All overloaded methods share the same name.
True (*)
False
Correct
(1/1) Points
13. Which statement is true?
You must write at least one constructor in your class.
The default constructor can accept arguments.
A constructor can be written to accept arguments. (*)
The default constructor is still available when you add your own constructor.
Correct
(1/1) Points
14. Method overloading can be a useful technique for defining methods with
similar functionality or calculations.
True (*)
False
Correct
(1/1) Points
15. You can write more than one constructor in a class.
True (*)
False
Correct
Section 8 Quiz
(Answer all questions in this section)
1. What is the output?

int[] array = {10, 20, 30};


int b = 0;
try{
System.out.println("1");
int c = (array[3] / b);
System.out.println("2");
}
catch(ArithmeticException ex){
System.out.println("Arithmetic Exception");
}
catch(ArrayIndexOutOfBoundsException ex){
System.out.println("Array index out of bounds");
}
1
Arithmetic Exception
1
Array index out of bounds (*)
1
2
Array index out of bounds
1
2
Array index out of bounds
Incorrect. Refer to Section 8 Lesson 3.
(0/1) Points
2. An exception is an error that occurs during the execution of a program at run-
time that disrupts the normal flow of the Java program.
True (*)
False
Correct
(1/1) Points
3. Each catch block is an exception handler that handles the type of exception
indicated by its argument.
True (*)
False
Correct
(1/1) Points
4. The Java compiler does not check for an ArrayIndexOutOfBoundsException
during the compilation of a program containing arrays.
True (*)
False
Correct
(1/1) Points
5. What is the output?
int[] arr = new int[2];
for(int i=0; i < arr.length; i++){
System.out.print("hai ");
}
hai hai (*)
hai
hai hai hai
12
Incorrect. Refer to Section 8 Lesson 1.
(0/1) Points
6. Given:
int x[];
What is the value of x?

1
0
Some random number.
null (*)
Incorrect. Refer to Section 8 Lesson 1.
(0/1) Points
7. Arrays are like variables which must be declared prior to use.
True (*)
False
Correct
(1/1) Points
8. Which two are valid array declarations?
(Choose all correct answers)
int array size;
int size[]; (*)
[]int size;
int[] size; (*)
Correct
(1/1) Points
9. An array allows you to create a single identifier that can be used to organize
many items of the same data type.
True (*)
False
Correct
(1/1) Points
10. Testing and debugging are important activities in software development.
True (*)
False
Correct
(1/1) Points
Previous

11. Runtime errors can be caught by Java’s exception handling mechanism.


True (*)
False
Correct
(1/1) Points
12. What are two advantages of adding print statements for debugging?
(Choose all correct answers)
You can identify which methods have been called. (*)
You can identify compilation errors.
You can identify runtime errors.
You can identify the order in which methods have been called. (*)
Correct
(1/1) Points
13. Which is not used to traverse an ArrayList?
do- while loop (*)
for-each loop
iterator
ListIterator
Incorrect. Refer to Section 8 Lesson 2.
(0/1) Points
14. How could you declare an ArrayList so that it can store true or false values?
ArrayList<true, false> arrList = new ArrayList<>();
ArrayList<True, False> arrList = new ArrayList<>();
ArrayList<Boolean> arrList = new ArrayList<>(); (*)
ArrayList<boolean> arrList = new ArrayList<>();
Incorrect. Refer to Section 8 Lesson 2.
(0/1) Points
15. Which two are limitations of an array of primitives (ie: int[] x)?
(Choose all correct answers)
You cannot overwrite the contents of an array once initialized.
The size of the array is fixed during array creation and cannot grow once
initialized. (*)
You need to create your own methods to manipulate array contents. (*)
You can create only one array in a class.
Incorrect. Refer to Section 8 Lesson 2.
(0/1) Points
Previous

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy