Java Programming Practice Questions and Answers, Exams of Nursing

A series of java practice test questions with their corresponding answers, designed to assess understanding of fundamental java concepts. It covers topics such as syntax, identifiers, compiler errors, output statements, data types, operators, and conditional statements. The questions are structured to help students reinforce their knowledge and prepare for exams or quizzes on java programming. It serves as a valuable resource for students learning java, providing a means to test their comprehension and identify areas for improvement. The content is suitable for beginners and those looking to review basic java concepts. Concise and focused, making it easy to use for quick self-assessment and study.

Typology: Exams

2024/2025

Available from 05/25/2025

bryanryan
bryanryan 🇺🇸

3.9

(8)

14K documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Java Practice Test Questions #1 And
Answers Graded A+
Q1: End-of-line comments that should be ignored by the compiler are denoted using
Correct Answer: Two forward slashes ( // ).
Q2: Which of the following is not a valid Java identifier? Correct Answer: m_x
Q3: Which of the following cannot cause a syntax error to be reported by the Java
compiler? Correct Answer: Extra blank lines.
Q4: Which of the following is not a syntax error? Correct Answer: System.out.println (
"Hello world!" );
Q5: Which command compiles the Java source code file Welcome.java? Correct
Answer: javac Welcome.java
Q6: Which command executes the Java class file Welcome? Class? Correct Answer:
java Welcome
Q7: Which is the output of the following statements?
System.out.print( "Hello ");
System.out.println( "World" ); Correct Answer: Hello World
Q8: Which of the following characters is the escape character? ___B___ Correct
Answer: \
Q9: Which of the following statements will print a single line containing "hello there"?
Correct Answer: System.out.print( "hello" );
System.out.println( " there" );
Q10: Which of the following statements would display the phase Java is fun? Correct
Answer: System.out.println( "\"Java is fun\"" );
Q11: When method printf requires multiple arguments, the arguments are separated
with Correct Answer: commas (,).
Q12: Which of the following statement displays Hello World? Correct Answer:
System.out.printf( "%s %s", "Hello", "World" );
Q13: All import declarations must be placed Correct Answer: before the class
declaration.
Q14: Which of the following is a variable declaration statement? Correct Answer: int
total;
pf3

Partial preview of the text

Download Java Programming Practice Questions and Answers and more Exams Nursing in PDF only on Docsity!

Java Practice Test Questions #1 And

Answers Graded A+

Q1: End-of-line comments that should be ignored by the compiler are denoted using Correct Answer: Two forward slashes ( // ). Q2: Which of the following is not a valid Java identifier? Correct Answer: m_x Q3: Which of the following cannot cause a syntax error to be reported by the Java compiler? Correct Answer: Extra blank lines. Q4: Which of the following is not a syntax error? Correct Answer: System.out.println ( "Hello world!" ); Q5: Which command compiles the Java source code file Welcome.java? Correct Answer: javac Welcome.java Q6: Which command executes the Java class file Welcome? Class? Correct Answer: java Welcome Q7: Which is the output of the following statements? System.out.print( "Hello "); System.out.println( "World" ); Correct Answer: Hello World Q8: Which of the following characters is the escape character? B Correct Answer:
Q9: Which of the following statements will print a single line containing "hello there"? Correct Answer: System.out.print( "hello" ); System.out.println( " there" ); Q10: Which of the following statements would display the phase Java is fun? Correct Answer: System.out.println( ""Java is fun"" ); Q11: When method printf requires multiple arguments, the arguments are separated with Correct Answer: commas (,). Q12: Which of the following statement displays Hello World? Correct Answer: System.out.printf( "%s %s", "Hello", "World" ); Q13: All import declarations must be placed Correct Answer: before the class declaration. Q14: Which of the following is a variable declaration statement? Correct Answer: int total;

Q15: enables a program to read data from the user. Correct Answer: Scanner. Q16: Which of the following is not a Java primitive type? Correct Answer: real Q17: The format specifier ________ is a place-holder for an int value? Correct Answer: %d. Q18: Which of the following statements does not alter a memory location?_______ Correct Answer: int a; Q19: What is the value of result after the following Java statements execute?_A int a, b, c, d, result; a = 4; b = 12; c = 37; d = 51; result = d % a * c + a % b + a; Correct Answer: 119 Q20: List the following operators in the order that they will be evaluated: - , *, /, +, %. Assume that if two operations have the same precedence, the one listed first will be evaluated first. Correct Answer: *, /, %, - , +. Q21: Which of the following is not an arithmetic operator? Correct Answer:. Q22: What will be output after the following Java statements have been executed? int a, b, c, d; a = 4; b = 12; c = 37; d = 51; if ( a < b ) System.out.println( "a < b" ); if ( a > b ) System.out.println( "a > b" ); if ( d <= c ) System.out.println( "d <= c" ); if ( c != d ) System.out.println( "c != d" ); Correct Answer: a. a < b c != d