CECS 174                                        QUIZ #1                           NAME:
                                                          20 points

Answers at the of the quiz

1. [3 points] How do you convert the source to the machine code? (Maximum 20 words for each answer or no credit)
Answer:

2.[ 3 points]  Rearrange the following steps are needed to execute Java program in the correct order.

link, load, edit, compile, execute

Answer

3. [4 points] Which of the following are illegal variable names , and why?  (-1 point for each each wrong answer)

abc
main
_profit
_sales__expenses
monthly_sales
123total
ab&cd
ab123cd

Answer

4. [4 points] Write one Java statement to display the following output:
Welcome

CECS 174
Java
Answer

 

5. [6 points] The following C++ program will not compile because the lines have been mixed up.

System.out.println("First example\n");
System.out.println("The values are:");
import javax.swing.*;
public static void main(String [] args)
public class Test
{
{
System.out.println("Java:");
System.out.println("and");
System.out.println("x = "+ x);
System.out.println("y= " +y);
int x = 10, y = 20;
System.exit(0);
}
}

Rearrange the lines in the correct order so the program should display the following on the screen:

Java:
First example

The values are:
x= 10
and
y= 20
end

Answer

 

 

 

 

 

 

 

 

 

Solution

1. compile the source code

2. edit, compile, link, load and execute

3. main -  key word
_sales__expenses - two underscores after sales
123total - no number at the first character
ab&cd -  no special symbol

4.
System.out.println("Welcome\n\nCECS174\nJava");

5.
import javax.swing.*;
public class Test
{ public static void main(String [] args)
  { int x = 10, y = 20;
System.out.println("Java:");
System.out.println("First example\n");
System.out.println("The values are:");
System.out.println("x =  "+ x);
System.out.println("and");
System.out.println("y=  " +y);
System.exit(0);
}
}