0% found this document useful (0 votes)
261 views

Website: Vce To PDF Converter: Facebook: Twitter:: 1Z0-811.Vceplus - Premium.Exam.75Q

This document contains a 75 question practice exam for the Oracle Certified Associate, Java SE 8 Programmer exam (1Z0-808). It provides multiple choice questions to test knowledge of Java programming concepts like primitive variables, methods, arrays, loops, exceptions and more. Each question includes an explanation of the correct answer. The document also provides the website URL where more free practice questions, online courses and tools can be accessed.

Uploaded by

Youssef Ibrahim
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)
261 views

Website: Vce To PDF Converter: Facebook: Twitter:: 1Z0-811.Vceplus - Premium.Exam.75Q

This document contains a 75 question practice exam for the Oracle Certified Associate, Java SE 8 Programmer exam (1Z0-808). It provides multiple choice questions to test knowledge of Java programming concepts like primitive variables, methods, arrays, loops, exceptions and more. Each question includes an explanation of the correct answer. The document also provides the website URL where more free practice questions, online courses and tools can be accessed.

Uploaded by

Youssef Ibrahim
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/ 52

1z0-811.VCEplus.premium.exam.

75q

Number: 1z0-811
Passing Score: 800
Time Limit: 120 min
File Version: 1.0

Website: https://vceplus.com - https://vceplus.co


VCE to PDF Converter: https://vceplus.com/vce-to-pdf/
Facebook: https://www.facebook.com/VCE.For.All.VN/
Twitter : https://twitter.com/VCE_Plus

1z0-811

Java Foundations

Version 1.0

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Exam A

QUESTION 1

Which statement is true about primitive variables?

A. They can be compared with the == operator.


B. They can be compared with the equals method only.
C. They cannot be compared.
D. They can be compared with the compareTo method only.

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Reference: https://stackoverflow.com/questions/9690981/compare-two-primitive-long-variables-in-java

QUESTION 2
Given the code fragment:

What is the result?

A. 2
B. 4
C. The program executes an infinite number of times.
D. 3

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 3 Identify two Java
reserved words.

A. array
B. true
C. this
D. exception
E. string

Correct Answer: BC
Section: (none)
Explanation

Explanation/Reference:
Reference:
https://www.computerhope.com/jargon/j/java_reserved_words.htm

QUESTION 4 Which statement is true about a


Java method?

A. It must be declared with an access modifier.


B. It cannot be defined within another method.
C. It must accept a parameter and return a value.
D. It cannot be defined as static final.

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.quora.com/Can-we-define-a-function-within-another-
function-in-Java

QUESTION 5
Given:

And the code fragment:

Which code fragment can be inserted at line n1 to enable the code to print All the best?

A. void writeMsg();
B. Messenger.writeMsg();
C. writeMsg();
D. m.writeMsg();

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:

QUESTION 6
Given the code fragment:

Which two code fragments are valid at line 2?

A. for (int count = 0; count < 5; count++)


{
System.out.print(count);
}
B. package p1;
C. import java.util.*; public void
display() { List<Integer> nums = new
ArrayList<> ();
}
D. { private int num;

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
}
E. private String name = “John”; public
void display() { System.out.print(name);
}

Correct Answer: BE
Section: (none)
Explanation

Explanation/Reference:

QUESTION 7 You have been asked to develop a Java program that prints the elements of an array in
reverse order.

Which looping statement cannot be used to meet the requirement?

A. enhanced for
B. standard for
C. while
D. do-while

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.javatpoint.com/java-program-to-print-the-elements-of-an-array-in-reverse-order

QUESTION 8
Given the code fragment:

Which statement is true?

A. The code results in a compilation error. To make it compile, insert at line n1:
import java.lang.Math; import java.lang.Random;
B. The code compiles successfully
C. The code results in a compilation error. To make it compile, insert at line n1:
import java.lang; import java.util;
D. The code results in a compilation error. To make it compile, insert at line n1:
import java.util.*;

Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 9
Given the code fragment:

What is the result?

A. pen pencil erasers paper


B. paper pen pencil erasers
C. A compilation error occurs.
D. A runtime exception is thrown.

Correct Answer: D
Section: (none)
Explanation

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Explanation/Reference:
Explanation:

QUESTION 10
Given the code fragment:

Which code fragment, when inserted at line n1, enables the code to print Java Programming:1?

A. System.out.println(name + “:” + count);


B. System.out.println(c.name + “:” + count);
C. System.out.println(c.name + “:” + Course.count);
D. System.out.println(Course.name + “:” + c.count);

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 11
Given:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
What is the result?

A. [null:-]
B. [ : ]
C. [null:null]
D. [:null]

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 12
Which two Java reserved words are used to implement encapsulation?

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
A. final
B. static
C. public
D. extends
E. private

Correct Answer: CE
Section: (none)
Explanation

Explanation/Reference:
Reference:
https://learn.saylor.org/mod/page/view.php?id=22044

QUESTION 13
Given the code fragment:

Which code fragment can be inserted at line n1 to enable the code to print 0.0?

A. Ball b = null;
b.weight = 0.0;
B. Ball.weight = 0.0;
C. Ball b = new Ball(0.0);
D. Ball b = new Ball();

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 14 Which two statements are true about the Java Runtime
Environment (JRE)?

A. It is responsible for garbage collection.


B. It interprets bytecode stored in a .class file.
C. It contains the JDK and Java APIs.
D. It is platform independent.
E. You must install the JRE to compile a .java file.

Correct Answer: BD
Section: (none)
Explanation

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Explanation/Reference:
Reference: https://en.wikipedia.org/wiki/Java_virtual_machine

QUESTION 15 Identify two


features of Java.

A. architecture dependent
B. platform independent
C. single threaded
D. robust

Correct Answer: BD
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.javatpoint.com/features-of-java

QUESTION 16
Given:

What is the result?

A. 300
B. 100
C. 200
D. A compilation error occurs.

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 17
Given the code fragment:

What is the result?

A. A compilation error occurs.


B. A runtime exception is thrown.
C. Julia
Peter
D. Peter
Julia

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 18
Given the code fragment:

Which code fragment can be inserted at line n1 to enable the code to compile?

A. new int num[];


B. int[] num;
C. int[10] num;
D. int num[10];
Correct Answer: B

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 19
Given the code fragment:

What is the result?

A. 9
12
B. 10
10
C. 9
9
D. 10
14

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 20
Given the code fragment:

What is the result?

A. Unknown issues.
Invalid divisor.
B. Unknown issues.
C. Invalid divisor.
D. A compilation error occurs.

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 21
Given the code fragment:

What is the result?

A. 3
B. A compilation error occurs.
C. 2
D. 0

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 22
Given the code fragment:

What is the result?

A. Selected null flavor.


B. Selected Chocolate flavor.
C. An ArrayIndexOutofBoundsException is thrown at run time.
D. Selected Chocolate flavor.
Thank you!

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 23
Given:

What is the result?

A. 100
200
B. A compilation error occurs at line n2.
C. A compilation error occurs at line n1.
D. 100 100 Correct Answer: D

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 24
Given:

And the code fragment:

What is the result?

A. A compilation error occurs at line n1.

B. White : null
C. null: null
D. White : White

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:

QUESTION 25
Given the code:

Which code fragment, when inserted at line n1, enables the code to print sum is 30?

A. int sum(int a, b) {
B. int sum(int a, int b) {
C. int sum(int, int) {
D. int sum(int[] a, b) {

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:

QUESTION 26 You have a microprocessor board, such as Raspberry PI, wired to


control a drone.

Which edition of Java is geared towards use of simple, closed systems with constrained memory requirements, such as a microprocessor board?

A. Java Micro Edition


B. Java Standard Edition with a Compact Profile
C. Java Enterprise Edition
D. Java SE Embedded

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.oracle.com/technical-
resources/articles/java/raspberrypi.html

QUESTION 27
Given the code fragment:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Which code fragment, when inserted at line n1, enables the code to print one?

A. char var = ‘1’;


B. String var = “1”;
C. int var = 1;
D. String var = 1;

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 28 Which statement is true about a


mutator method?

A. It replaces the default constructor.


B. It returns mutated instance members.
C. It must be declared private.
D. It can be used to assign data to instance members.

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Reference:
https://core.ac.uk/download/pdf/4824892.pdf

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 29
Given the code fragment:

What is the result?

A. false
false
false
false
B. true
false
false
false
C. true
true
true
true D.
true
true
true
false

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 30 Identify two valid data types for the operands of the addition
(+) operator?

A. string
B. boolean
C. numeric
D. array

Correct Answer: AD
Section: (none)
Explanation

Explanation/Reference:
Reference:
https://www.iitk.ac.in/esc101/05Aug/tutorial/java/nutsandbolts/arithmetic.html

QUESTION 31
Given the code fragment:

What is the result?

A. false false –1
B. true false 0
C. true true 0
D. false true –1

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 32
Given the code fragment:

Which statement is true?

A. A compilation error occurs at line 5.


B. A compilation error occurs at line 3.
C. The code compiles without errors.
D. A compilation error occurs at line 7.

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 33 Identify two
class variables.

A. private static int numberOfSquares = 20;


B. public static int counter = 0;
C. private Measure cm;
D. public int size = 10;
E. int scale = 35;

Correct Answer: AB
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.tutorialspoint.com/What-are-class-variables-instance-variables-and-local-variables-in-Java

QUESTION 34 Which
statement is valid?

A. int 2 totalScore = 0;
B. int total–score = 0;
C. int totalScore2 = 0;
D. int total score = 0;

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Reference: https://liveexample.pearsoncmg.com/html/TotalScore.html

QUESTION 35
Given these class definitions:

Which class or classes compile?

A. only MyClassB, MyClassC, and MyClassD


B. only MyClassB
C. MyClassA, MyClassB, MyClassC, and MyClassD
D. only MyClassB and MyClassD

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:

QUESTION 36
Given:

Which statement, when inserted at line n1, enables the Course class to compile?

A. int newFee;
B. double newFee;
C. long newFee;
D. float newFee; Correct Answer: B Section: (none) Explanation

Explanation/Reference:

QUESTION 37
Given:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
What is the result?

A. The code fails to compile. To make it compile, at line n1 insert: this


() { }
B. The code fails to compile. To make it compile, at line n2 insert: this
();
C. The code fails to compile. To make it compile, at line n1 insert: Bus
() { }
D. The code compiles and prints:default luxury

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 38
Given:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
At which line does a compilation error occur?

A. line 5
B. line 2
C. line 3
D. line 7

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:

QUESTION 39
Given:

What is the result?

A. 20
B. 32
C. A compilation error occurs.
D. 21

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 40
Given the classes:

Which two modifications, independently, enable the Salad.java file to compile?

A. Replace line n1 with import fruits.Apple.getApple();


B. Replace line n1 with import fruits.Apple;
C. Replace line n1 with import fruits;
D. Replace line n2 with fruits.Apple apple = new Apple ();
E. Replace line n2 with fruits.Apple apple = new fruits.Apple ();

Correct Answer: AD
Section: (none)
Explanation

Explanation/Reference:
QUESTION 41

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Given the code fragment:

What is the result?

A. 456789
B. 4567889 C. 45678
D. 3456789

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 42
Given the code fragment:

What is the result?

A. 10 20
10 15 20
B. A runtime exception is thrown.
C. 10 20
10 20

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
D. A compilation error occurs.

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 43 Which statement is true about


exception handling?

A. At least one catch block must accompany a try statement.


B. All statements in a try block are executed, even if an exception occurs in the middle of the try block.
C. At least one statement in a try block must throw an exception.
D. All catch blocks must be ordered from general to most specific.

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.javatpoint.com/multiple-catch-block-in-java

QUESTION 44
Given the code fragment:

What is the result?

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
A. true
true B.
true
false
C. false
false
D. false
true

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 45
Given the code fragment:

What is the result?

A. 10
B. 11
C. 12
D. 13

Correct Answer: C

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 46
Given the code fragment:

What is the result?

A. [ BETATEST ]
B. [betaTest]
C. [ betaTest ]
D. [BETATEST]
Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 47
Given the code

What is the result?

A. The program executes indefinitely.


B. num = 100
C. num = 99
D. num = 0

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 48 Which method identifier is correct according to Java naming
conventions?

A. BillCalculator
B. calculateBill
C. calculatebill
D. Calculator

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:

QUESTION 49 Given the contents of


Student.java:

Which statement is true? A.

The commands: javac

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Student.java java

Student Richard

William Java throw an

error about a missing

Course.class file. B. The

commands: javac

Course.java javac

Student.java java

Course java Student

“Richard William”

Java are used to print

Richard William is

studying Java. C. The

commands: javac

Student.java java

Student Richard

William Java are used

to print Richard William

is studying Java. D.

The commands: javac

Student.java java

Student “Richard

William” Java are used

to print Richard William

is studying Java.

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:

QUESTION 50

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Given the code fragment:

At which line does a compilation error occur?

A. lines 5 and 7
B. line 7
C. lines 6 and 8
D. line 5

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:

QUESTION 51
Given the code fragment:

Which for loop statement can be used to print 135?

A. for(int idx = 1; idx < arr.length; idx+=2) {


System.out.print (arr[idx]);
}
B. for(int idx = 1; idx < arr.length–1; idx++) {
System.out.print (arr[idx++]);
}
C. for(int idx = 0; idx < arr.length; idx++) {
System.out.print (arr[idx]);
}
D. for(int idx = 0; idx < arr.length; idx+=2) {
System.out.print (arr[idx]);
}

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 52
Given the code fragment:

What is the result?

A. false
false
B. true
true C.
true
false
D. false
true

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 53
Given:

Which statement is true about the main method?

A. It can be a non-static method.


B. Its parameter can be of type Integer [].
C. It cannot be defined in a non-public class.
D. It cannot be invoked by its name.

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:

QUESTION 54
Given the code fragment:

Which code fragment, when inserted at line n1, enables it to print Rita is 14 years old?

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
A. System.out.println(“%s is %d years old” +name+age);
B. System.out.println(“%s is %n years old” name, age);
C. System.out.printf(“%s is %d years old”, name, age);
D. System.out.printf(“%s is %n years old”, name, age);

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 55
Given:

What is the result?

A. A compilation error occurs in the modify method.


B. 99

C. 5
D. A compilation error occurs in the main method.

Correct Answer: D
Section: (none)
Explanation

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Explanation/Reference:
Explanation:

QUESTION 56 What does import


java.io* mean?

A. Only the io class is imported.


B. All classes in the io package are imported.
C. All classes whose names start with io are imported.
D. All classes in the io package and the subpackages of io packages, if any, are imported.

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:

QUESTION 57
Given:

What is the result?

A. Compilation fails. To make it compile, replace line n1 with var1 = 0; B.


Compilation fails. To make it compile, replace line n2 with var2 = 0;

C. 0
D. Nothing is printed.

Correct Answer: B
Section: (none)
Explanation

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Explanation/Reference:
Explanation:

QUESTION 58
Given the code fragment:

What is the result?

A. 1
B. 3
C. 5
D. Nothing is printed.

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 59 What is the meaning of “write once, run
anywhere” in Java?

A. Java programs are designed to run only in web browsers and, thus, can run wherever there is a browser.
B. It is a marketing statement because Java programs must be compiled for a specific platform in order to run.
C. Java programs can run on any Java Virtual Machine without being recompiled.
D. Java programs, after being compiled, can run on any platform or device even without a Java Virtual Machine.

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.geeksforgeeks.org/why-is-java-write-once-and-run-
anywhere/

QUESTION 60
Given the code fragment:

What is the result?

A. [jasmine, rose, lily]


B. A runtime exception is thrown.
C. [jasmine, lily, lotus]
D. [jasmine, rose, lotus, lily]

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 61
Given the code fragment:

Which statement, when inserted at line n1, enables the code to print 0 2 4 6 8 10?

A. count = (count++) +1;


B. count = count++;
C. count =+ 2;
D. count += 2;

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 62
Given the code fragment:

What is the result?

A. 3 : 1
B. 3 : 2
C. 0 : 1
D. 2 : 0

Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 63 Identify three advantages of object-oriented
programming.

A. separation of state and behavior


B. modularity
C. information sharing
D. code reuse
E. information hiding

Correct Answer: BDE


Section: (none)
Explanation

Explanation/Reference:
Reference:
https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm

QUESTION 64
Given the code fragment:

What is the result?

A. 25.67
B. 25.00
C. 25.7
D. 26

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 65 Identify three features of the Java
programming language.

A. distributed
B. direct memory management
C. multithreaded
D. strongly typed
E. dynamically typed

Correct Answer: ACE


Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.tutorialspoint.com/What-are-the-major-features-of-Java-
programming

QUESTION 66
Given the code fragment:

What is the result?

A. false
true B.
true
true
C. false false
D. A runtime exception is thrown

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Correct Answer: B
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 67
Given the code fragment:

What is the result?

A. lotus jasmine
B. lotus
C. A compilation error occurs.
D. lotus lily
Correct Answer: D
Section: (none)
Explanation

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Explanation/Reference:
Explanation:

QUESTION 68
Given the code fragment:

What is the output?

A. 8
B. 3
C. 0
D. A compilation error occurs.

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 69
Given the code fragment:

What is the result?

A. a memory address1 in hexadecimal number format


a memory address2 in hexadecimal number format B.
10, 15
[10, 15]
C. 0, 10, 15
[10, 15, null]
D. a memory address in hexadecimal number format
[10, 15]

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 70
Given the code fragment:

What is the result?

A. A compilation error occurs at line n1.


B. Jack
C. The program prints either Jack or Queen.
D. Queen

Correct Answer: A
Section: (none)
Explanation

Explanation/Reference:
Explanation:

QUESTION 71

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
Which package would you import to use the Random class?

A. java.io
B. java.math C. java.util
D. java.lang

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Reference: https://www.educative.io/edpresso/how-to-generate-random-numbers-in-
java

QUESTION 72 Which two components can class


declarations include?

A. A list of instance methods


B. The main method
C. Interfaces implemented by the class
D. The public modifier

Correct Answer: CD
Section: (none)
Explanation

Explanation/Reference:
Reference: https://docs.oracle.com/javase/tutorial/java/javaOO/classdecl.html

QUESTION 73
Given:

What is the output?

A. 1 2 3 aaaa
B. 1 2 aaa
C. Compilation fails
D. a

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
QUESTION 74
Given:

What is the result?

A. The program compiles and nothing is printed.


B. Iteration plus an increasing number is printed 100 times.
C. Iteration plus an increasing number is printed 99 times.
D. An error occurs during compilation.

Correct Answer: D
Section: (none)
Explanation

Explanation/Reference:

QUESTION 75
Given the contents of the Test.java file:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com
What is the result?

A. 200 : 400 B. A compilation error


occurs at line n1.
C. A compilation error occurs at line n2.
D. 100 : 400

Correct Answer: C
Section: (none)
Explanation

Explanation/Reference:
Explanation:

www.vceplus.com - Free Questions & Answers - Online Courses - Convert VCE to PDF - VCEplus.com

You might also like