CIT 174 1-5 EXAM QUESTIONS WITH
CORRECT ANSWERS
An |example |of |an |output |device |that |interfaces |between |computers |and |humans |is |- |CORRECT
|ANSWER✔✔-A |speaker
What |is |the |difference |between |an |editor |and |a |compiler? |- |CORRECT |ANSWER✔✔-An |editor |
allows |program |files |to |be |written |and |stored; |a |compiler |converts |program |files |into |an |
executable |program
Every |Java |program |consists |of |one |or |more |- |CORRECT |ANSWER✔✔-classes
Which |of |the |following |symbols |is |used |to |terminate |a |Java |program |statement? |- |CORRECT |
ANSWER✔✔-Semicolon
A |Java |class |with |the |name |"Printer" |has |to |be |saved |using |the |source |file |name: |- |CORRECT |
ANSWER✔✔-Printer.java
When |a |compiler |finds |a |syntax |error |in |a |program, |what |happens? |- |CORRECT |ANSWER✔✔-
The |compiler |continues |and |may |report |about |other |errors |but |does |not |produce |a |Java |class |
file
Which |one |of |the |following |errors |represents |a |part |of |a |program |that |is |incorrect |according |
to |the |rules |of |the |programming |language? |- |CORRECT |ANSWER✔✔-Syntax |errors
Imagine |you |are |developing |an |algorithm |to |calculate |the |total |cost |of |a |purchase |order |that |
contains |several |items. |The |cost |of |each |item |and |the |tax |rate |is |known. |The |standard |shipping
|charge |for |the |entire |order |is |$4.95, |and |the |special |delivery |charge |is |$19.95. |In |addition, |
there |is |no |tax |on |the |shipping |cost. |Which |of |the |following |is |the |correct |pseudocode |for |the |
required |algorithm? |- |CORRECT |ANSWER✔✔-For |each |item |on |the |purchase |order:
,| Order |cost |= |order |cost |+ |item |cost
If |standard |shipping
| Shipping |cost |= |4.95
Else
| Shipping |cost |= |19.95
Total |purchase |order |cost |= |order |cost |* |tax |rate |+ |shipping |cost
What |is |the |purpose |of |the |following |algorithm, |written |in |pseudocode?
num |= |0
Repeat |the |following |steps |10 |times
Input |var1
If |var1 |> |num
Num |= |var1
Print |num |- |CORRECT |ANSWER✔✔-To |find |the |highest |among |10 |numbers
Consider |the |following |pseudocode, |what |does |it |produce?
Set |n |= |1.
Set |p |= |0.
Set |s |= |0.
Repeat |until |n |equals |10
Calculate |the |square |of |n |and |store |in |s. |Add |s |to |p.
Add |1 |to |n.
Print |p. |- |CORRECT |ANSWER✔✔-Sum |of |square |of |numbers |between |1 |and |10
A |Java |Virtual |Machine |is |- |CORRECT |ANSWER✔✔-A |program |that |simulates |a |real |CPU
,A |Java |"class" |file |- |CORRECT |ANSWER✔✔-contains |instructions |to |the |Java |virtual |machine
What |is |the |result |of |the |following |code |snippet?
| public |static |void |main(String[ |] |args)
{
| double |circleRadius;
| double |circleVolume |= |22 |/ |7 |* |circleRadius |* |
circleRadius;
| System.out.println(circleVolume);
} |- |CORRECT |ANSWER✔✔-compiletime |error
What |is |wrong |with |the |following |code |snippet?
public |class |Area
{
| public |static |void |main(String[] |args)
| {
| int |width |= |10;
| height |= |20.00;
| System.out.println("area |= |" |+ |(width |* |height));
} |} |- |CORRECT |ANSWER✔✔-The |code |snippet |uses |an |undeclared |variable.
What |will |be |the |value |stored |in |the |variable |x |after |the |execution |of |the |following |code |
snippet?
int |a |= |10;
int |b |= |20;
int |c |= |2;
, int |x |= |b |/ |a |/*c*/; |- |CORRECT |ANSWER✔✔-2
Which |one |of |the |following |variables |is |assigned |with |valid |literals? |look |at |the |types |- |
CORRECT |ANSWER✔✔-double |salary2 |= |0;
salary2 |= |2.96E-2;
because |double |is |initialized |to |the |correct |type
Assuming |that |the |user |inputs |a |value |of |25 |for |the |price |and |10 |for |the |discount |rate |in |the |
following |code |snippet, |what |is |the |output?
public |static |void |main(String[] |args)
{
| Scanner |in |= |new |Scanner(System.in);
| System.out.print("Enter |the |price: |");
| double |price |= |in.nextDouble();
| System.out.print("Enter |the |discount |rate: |");
| double |discount |= |in.nextDouble();
| System.out.println("The |new |price |is |" |+
} |- |CORRECT |ANSWER✔✔-The |new |price |is |22.5 |
do |the |math |25-25*(10/100)
What |output |is |produced |by |these |statements?
String |name |= |"Joanne |Hunt";
System.out.println(name.length()); |- |CORRECT |ANSWER✔✔-letter+spaces |=11
What |is |the |output |of |the |following |code |snippet?
public |static |void |main(String[] |args){
{
CORRECT ANSWERS
An |example |of |an |output |device |that |interfaces |between |computers |and |humans |is |- |CORRECT
|ANSWER✔✔-A |speaker
What |is |the |difference |between |an |editor |and |a |compiler? |- |CORRECT |ANSWER✔✔-An |editor |
allows |program |files |to |be |written |and |stored; |a |compiler |converts |program |files |into |an |
executable |program
Every |Java |program |consists |of |one |or |more |- |CORRECT |ANSWER✔✔-classes
Which |of |the |following |symbols |is |used |to |terminate |a |Java |program |statement? |- |CORRECT |
ANSWER✔✔-Semicolon
A |Java |class |with |the |name |"Printer" |has |to |be |saved |using |the |source |file |name: |- |CORRECT |
ANSWER✔✔-Printer.java
When |a |compiler |finds |a |syntax |error |in |a |program, |what |happens? |- |CORRECT |ANSWER✔✔-
The |compiler |continues |and |may |report |about |other |errors |but |does |not |produce |a |Java |class |
file
Which |one |of |the |following |errors |represents |a |part |of |a |program |that |is |incorrect |according |
to |the |rules |of |the |programming |language? |- |CORRECT |ANSWER✔✔-Syntax |errors
Imagine |you |are |developing |an |algorithm |to |calculate |the |total |cost |of |a |purchase |order |that |
contains |several |items. |The |cost |of |each |item |and |the |tax |rate |is |known. |The |standard |shipping
|charge |for |the |entire |order |is |$4.95, |and |the |special |delivery |charge |is |$19.95. |In |addition, |
there |is |no |tax |on |the |shipping |cost. |Which |of |the |following |is |the |correct |pseudocode |for |the |
required |algorithm? |- |CORRECT |ANSWER✔✔-For |each |item |on |the |purchase |order:
,| Order |cost |= |order |cost |+ |item |cost
If |standard |shipping
| Shipping |cost |= |4.95
Else
| Shipping |cost |= |19.95
Total |purchase |order |cost |= |order |cost |* |tax |rate |+ |shipping |cost
What |is |the |purpose |of |the |following |algorithm, |written |in |pseudocode?
num |= |0
Repeat |the |following |steps |10 |times
Input |var1
If |var1 |> |num
Num |= |var1
Print |num |- |CORRECT |ANSWER✔✔-To |find |the |highest |among |10 |numbers
Consider |the |following |pseudocode, |what |does |it |produce?
Set |n |= |1.
Set |p |= |0.
Set |s |= |0.
Repeat |until |n |equals |10
Calculate |the |square |of |n |and |store |in |s. |Add |s |to |p.
Add |1 |to |n.
Print |p. |- |CORRECT |ANSWER✔✔-Sum |of |square |of |numbers |between |1 |and |10
A |Java |Virtual |Machine |is |- |CORRECT |ANSWER✔✔-A |program |that |simulates |a |real |CPU
,A |Java |"class" |file |- |CORRECT |ANSWER✔✔-contains |instructions |to |the |Java |virtual |machine
What |is |the |result |of |the |following |code |snippet?
| public |static |void |main(String[ |] |args)
{
| double |circleRadius;
| double |circleVolume |= |22 |/ |7 |* |circleRadius |* |
circleRadius;
| System.out.println(circleVolume);
} |- |CORRECT |ANSWER✔✔-compiletime |error
What |is |wrong |with |the |following |code |snippet?
public |class |Area
{
| public |static |void |main(String[] |args)
| {
| int |width |= |10;
| height |= |20.00;
| System.out.println("area |= |" |+ |(width |* |height));
} |} |- |CORRECT |ANSWER✔✔-The |code |snippet |uses |an |undeclared |variable.
What |will |be |the |value |stored |in |the |variable |x |after |the |execution |of |the |following |code |
snippet?
int |a |= |10;
int |b |= |20;
int |c |= |2;
, int |x |= |b |/ |a |/*c*/; |- |CORRECT |ANSWER✔✔-2
Which |one |of |the |following |variables |is |assigned |with |valid |literals? |look |at |the |types |- |
CORRECT |ANSWER✔✔-double |salary2 |= |0;
salary2 |= |2.96E-2;
because |double |is |initialized |to |the |correct |type
Assuming |that |the |user |inputs |a |value |of |25 |for |the |price |and |10 |for |the |discount |rate |in |the |
following |code |snippet, |what |is |the |output?
public |static |void |main(String[] |args)
{
| Scanner |in |= |new |Scanner(System.in);
| System.out.print("Enter |the |price: |");
| double |price |= |in.nextDouble();
| System.out.print("Enter |the |discount |rate: |");
| double |discount |= |in.nextDouble();
| System.out.println("The |new |price |is |" |+
} |- |CORRECT |ANSWER✔✔-The |new |price |is |22.5 |
do |the |math |25-25*(10/100)
What |output |is |produced |by |these |statements?
String |name |= |"Joanne |Hunt";
System.out.println(name.length()); |- |CORRECT |ANSWER✔✔-letter+spaces |=11
What |is |the |output |of |the |following |code |snippet?
public |static |void |main(String[] |args){
{