CSCI 2010 MIDTERM
fully solved
2025(graded A+)
If you compile a java source file containing a definition of class
called MyApp, what is the name of the file that contains the results -
answer MyApp.class
Given the code:
String greeting = "Hello there!";
System.out.println(greeting.length());
What is displayed to the screen? - answer 12
Which of the following objects is used to display normal output to
the screen? - answer System.out
Which of the following statements reads a number from the
keyboard? - answer number = keyboard.nextInt();
Which of the following keywords is NOT required when declaring a
named constant?
final
void
public
static - answer void
, The java compiler translates source code written in Java into which
of the following languages? - answer Bytecode
Which of the following is used to display formatted output? - answer
System.out.printf
What is the relationship between a class and an object? - answer A
class is a blueprint for creating objects
Which of the following statements does NOT increase the value of
the variable number by 1?
number += 1
number + 1
number = number + 1
number ++ - answer number + 1
which of the following is the correct way to test if two strings s1 and
s2 are exactly the same? - answer s1.equals(s2)
What is the difference between a while loop and a do-while loop -
answer A while loop evaluates its controlling boolean expression
before the body is executed.
A do-while loop evaluates its controlling boolean after the loop is
executed
Why is it a good idea to use a DEBUG flag when tracing variables? -
answer the DEBUG flag allows the programmer to easily turn the
tracing messages on and off
fully solved
2025(graded A+)
If you compile a java source file containing a definition of class
called MyApp, what is the name of the file that contains the results -
answer MyApp.class
Given the code:
String greeting = "Hello there!";
System.out.println(greeting.length());
What is displayed to the screen? - answer 12
Which of the following objects is used to display normal output to
the screen? - answer System.out
Which of the following statements reads a number from the
keyboard? - answer number = keyboard.nextInt();
Which of the following keywords is NOT required when declaring a
named constant?
final
void
public
static - answer void
, The java compiler translates source code written in Java into which
of the following languages? - answer Bytecode
Which of the following is used to display formatted output? - answer
System.out.printf
What is the relationship between a class and an object? - answer A
class is a blueprint for creating objects
Which of the following statements does NOT increase the value of
the variable number by 1?
number += 1
number + 1
number = number + 1
number ++ - answer number + 1
which of the following is the correct way to test if two strings s1 and
s2 are exactly the same? - answer s1.equals(s2)
What is the difference between a while loop and a do-while loop -
answer A while loop evaluates its controlling boolean expression
before the body is executed.
A do-while loop evaluates its controlling boolean after the loop is
executed
Why is it a good idea to use a DEBUG flag when tracing variables? -
answer the DEBUG flag allows the programmer to easily turn the
tracing messages on and off