Вы находитесь на странице: 1из 25

98-388.

16q

Number: 98-388
Passing Score: 800
Time Limit: 120 min
File Version: 1.0

98-388

https://www.gratisexam.com/

Introduction to Programming Using Java

Sections
1. Understand Java fundamentals
2. Work with data types, variables, and expressions
3. Implement flow control
4. Compile and debug code

https://www.gratisexam.com/
Exam A

QUESTION 1
You have the following code segment. Line numbers are included for reference only.

https://www.gratisexam.com/

What is the output of line 07?

A. -44
B. -40.0
C. 40.0
D. 44.0

Correct Answer: B
Section: Understand Java fundamentals
Explanation

Explanation/Reference:

QUESTION 2
You need to analyze the following code segment. Line numbers are included for reference only.

https://www.gratisexam.com/
What is the output of line 12 when you run printInt()?

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

Correct Answer: A
Section: Understand Java fundamentals
Explanation

Explanation/Reference:

QUESTION 3
HOTSPOT

You are creating a Java console application.

You need to read a birthdate entered by the user.

https://www.gratisexam.com/
How should you complete the code? To answer, select the appropriate code segments in the answer area.

NOTE: Each correct selection is worth one point.

Hot Area:

https://www.gratisexam.com/
Correct Answer:

Section: Understand Java fundamentals


Explanation

Explanation/Reference:

https://www.gratisexam.com/
References:
https://docs.oracle.com/javase/7/docs/api/java/io/InputStreamReader.html

QUESTION 4
DRAG DROP

You need to evaluate the following Java program. Line numbers are included for reference only.

Which three values will be displayed in sequence? To answer, move the appropriate values from the list of values to the answer area and arrange them in the
correct order.

NOTE: Each correct selection is worth one point.

Select and Place:

https://www.gratisexam.com/
Correct Answer:

Section: Understand Java fundamentals


Explanation

Explanation/Reference:

QUESTION 5
HOTSPOT

You need to evaluate the following code. Line numbers are included for reference only.

https://www.gratisexam.com/
Use the drop-down menus to select the answer choice that answers each question based on the information presented in the code.

NOTE: Each correct selection is worth one point.

Hot Area:

https://www.gratisexam.com/
Correct Answer:

https://www.gratisexam.com/
Section: Work with data types, variables, and expressions
Explanation

Explanation/Reference:

QUESTION 6
DRAG DROP

You have the following code:

https://www.gratisexam.com/
You need to create an int array named numbers initialized with num1, num2, and num3.

How should you complete the code? To answer, drag the appropriate code segment to the correct position. Each code segment may be used once, more than
once, or not at all. You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

Correct Answer:

Section: Work with data types, variables, and expressions


Explanation

Explanation/Reference:
Example:
int[] numbers = new int[] {num1, num2, num3}

References:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

https://www.gratisexam.com/
https://alvinalexander.com/blog/post/java/java-faq-create-array-int-example-syntax

QUESTION 7
HOTSPOT

You are writing a Java program.

The program must meet the following requirements:

Truncate firstName to its first five characters


Set output to a string that contains the firstName and the number of characters in firstName

How should you complete the code? To answer, select the appropriate code segments in the answer area.

NOTE: Each correct selection is worth one point.

Hot Area:

Correct Answer:

https://www.gratisexam.com/
Section: Work with data types, variables, and expressions
Explanation

Explanation/Reference:
References:
https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html

https://www.tutorialspoint.com/java/lang/stringbuilder_substring_end.htm

QUESTION 8
DRAG DROP

You are writing a Java method that evaluates an arithmetic formula.

The method accepts an int value named number, raises the value to the second power, and returns the negative value of the result.

How should you complete the code? To answer, drag the appropriate code segment to the correct position. Each code segment may be used once, more than
once, or not at all. You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

https://www.gratisexam.com/
Correct Answer:

Section: Work with data types, variables, and expressions


Explanation

Explanation/Reference:

QUESTION 9
The question requires that you evaluate the underlined text to determine if it is correct.

You should use an int data type to store the numeric value 3,000,000,000 (3 billion) so that the least amount of memory is used.

Review the underlined text. If it makes the statement correct, select “No change is needed.” If the statement is incorrect, select the answer choice that makes the
statement correct.

A. No change is needed.
B. a short
C. a byte
D. a long

https://www.gratisexam.com/
https://www.gratisexam.com/

Correct Answer: D
Section: Work with data types, variables, and expressions
Explanation

Explanation/Reference:

QUESTION 10
You need to evaluate the following code segment:

What happens when the code segment is run?

A. iNum has a value of 0.


B. An exception is thrown.
C. iNum has a value of 2.
D. iNum has a value of 3.

Correct Answer: C
Section: Work with data types, variables, and expressions
Explanation

Explanation/Reference:

QUESTION 11
DRAG DROP

https://www.gratisexam.com/
You are writing a Java method.

The program must meet the following requirements:

Accept a String parameter firstName


Display a welcome message that contains firstName
Ensure that the first letter of the name is capitalized, and the remaining letters are in lowercase

How should you complete the code? To answer, drag the appropriate code segment to the correct position. Each code segment may be used once, more than
once, or not at all. You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

Correct Answer:

https://www.gratisexam.com/
Section: Work with data types, variables, and expressions
Explanation

Explanation/Reference:
References:
http://www.tutorialspoint.com/java/java_strings.htm

QUESTION 12
You work as a Java programmer.

You need to convert a numeric String to a primitive double value.

What code segment should you use?

A. Double.valueOf(numberString);
B. double.parseDouble(numberString);
C. String.parseDouble(numberString);
D. Double.parseDouble(numberString);

Correct Answer: B
Section: Work with data types, variables, and expressions
Explanation

Explanation/Reference:
References:
https://www.javacodeexamples.com/convert-string-to-primitive-example/140

QUESTION 13
HOTSPOT

You are writing a Java console program. The program accepts command line arguments.

You need to ensure that the main method parses and handles each command line argument.

How should you complete the code? To answer, select the appropriate code segments in the answer area.

NOTE: Each correct selection is worth one point.

Hot Area:

https://www.gratisexam.com/
Correct Answer:

https://www.gratisexam.com/
Section: Work with data types, variables, and expressions
Explanation

Explanation/Reference:

QUESTION 14
HOTSPOT

You are writing a Java method.

https://www.gratisexam.com/
The method must meet the following requirements:

Accept a String array named entries


Iterate through entries
Stop the iteration and return false if any element has more than 10 characters
Otherwise, return true

How should you complete the code? To answer, select the appropriate code segments in the answer area.

NOTE: Each correct selection is worth one point.

Hot Area:

https://www.gratisexam.com/
Correct Answer:

https://www.gratisexam.com/
Section: Implement flow control
Explanation

Explanation/Reference:

https://www.gratisexam.com/
QUESTION 15
DRAG DROP

Traders hires you to write a Java program to manage account openings.

To open a new account, a user must meet one the following requirements:

be over 65 years old and have a minimum annual income of 10,000


be at least 21 and have an annual income greater than 25,000

How should you complete the code? To answer, drag the appropriate operator to the correct position. Each operator may be used once, more than once, or not at
all. You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

Correct Answer:

https://www.gratisexam.com/
Section: Implement flow control
Explanation

Explanation/Reference:
References:
https://www.tutorialspoint.com/java/java_basic_operators.htm

QUESTION 16
The question requires that you evaluate the underlined text to determine if it is correct.

You have the following class definition:

The logError method can be invoked by code in all classes in the same package as the Logger class.

Review the underlined text. If it makes the statement correct, select “No change is needed.” If the statement is incorrect, select the answer choice that makes the
statement correct.

A. No change is needed
B. only by the Logger class
C. only by the Logger class and classes in the same package that inherit from it
D. by all classes in all packages

Correct Answer: C
Section: Compile and debug code
Explanation

Explanation/Reference:

https://www.gratisexam.com/
https://www.gratisexam.com/

https://www.gratisexam.com/

Вам также может понравиться