O'Reilly logo

OCA Java SE 8 Programmer Study Guide (Exam 1Z0-808) by Budi Kurniawan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix D

Mock Exam 2 Answers

The following are answers to the questions in the second mock exam. Each question may have more than one correct answer and you have to choose all the correct answers.

Question 1 (1.3. Create executable Java applications with a main method; run a Java program from the command line; including console output)

Consider the following code.

 

package demo;

public class MainDemo {

    public static void main(String[] args) {

        System.out.println(args[0]);

    }

}

It is invoked with this command line command:

java demo.MainDemo 20+30

What is printed on the standard out?

 

A.  50

B.  20

C.  30

D.  20+30

Answer: D.

Program arguments are not evaluated. Thus, 20+30 is passed on to the main method as is.

Question 2 (1.3. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required