Exam 2: Data and Expressions
Exam 1: Introduction65 Questions
Exam 2: Data and Expressions77 Questions
Exam 3: Using Classes and Objects58 Questions
Exam 4: Writing Classes56 Questions
Exam 5: Conditionals and Loops37 Questions
Exam 6: More Conditionals and Loops36 Questions
Exam 7: Object-Oriented Design76 Questions
Exam 8: Arrays70 Questions
Exam 9: Inheritance71 Questions
Exam 10: Polymorphism70 Questions
Exam 11: Exceptions68 Questions
Exam 12: Recursion68 Questions
Exam 13: Collections68 Questions
Select questions type
What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5?
(Multiple Choice)
4.7/5
(34)
For the following questions, refer to the class defined below:
import java.util.Scanner;
public class Questions33_34
{
public static void main(String[ ] args)
{
int x, y, z;
double average;
Scanner scan = new Scanner(System.in);
System.out.println("Enter an integer value");
x = scan.nextInt( );
System.out.println("Enter another integer value");
y = scan.nextInt( );
System.out.println("Enter a third integer value");
z = scan.nextInt( );
average = (x + y + z) / 3;
System.out.println("The result of my calculation is " + average);
}
}
-What is output if x = 0, y = 1 and z = 1?
(Multiple Choice)
4.8/5
(40)
Consider the following paint method and answer the questions below:
public void paint(Graphics page)
{
page.setColor(Color.blue);
page.fillRect(50, 50, 100, 100);
page.setColor(Color.white);
page.drawLine(50, 50, 150, 150);
page.drawLine(50, 150, 150, 50);
page.setColor(Color.black);
page.drawString("A nice box", 50, 170);
}
-The figure drawn in this applet is
(Multiple Choice)
4.8/5
(32)
What value will z have if we execute the following assignment statement?
Float z = 5 / 10;
(Multiple Choice)
4.8/5
(36)
Provide three examples of code using assignment statements where one assignment statement would result in a syntax error, one would result in a logical error, and one would result in a run-time error.
(Essay)
4.9/5
(48)
Suppose that String name = "Frank Zappa". What will the instruction name.toUpperCase( ).replace('A', 'I'); return?
(Multiple Choice)
4.7/5
(34)
Java is a strongly typed language. What is meant by "strongly typed"?
(Multiple Choice)
4.9/5
(39)
Write a program that will input some number of cents (less than 100) and output the number of quarters, dimes, nickels and pennies needed to add up to that amount.
(Essay)
4.8/5
(35)
An applet is 200x200. Write the Strings "North", "South", "East", and "West" at the four edges of the applet where they should appear as if on a map. Use the color black for the text.
(Essay)
4.8/5
(41)
What is output with the statement System.out.println(""+x+y); if x and y are int values where x=10 and y=5?
(Multiple Choice)
4.8/5
(49)
The values of (double) 5 / 2 and (double) (5 / 2) are identical.
(True/False)
4.7/5
(36)
Assume that x is a double that stores 0.362491. To output this value as 36%, you could use the NumberFormat class with NumberFormat nf = NumberFormat.getPercentInstance( ); Which of the following statements then would output x as 36%?
(Multiple Choice)
4.9/5
(46)
You cannot cast a String to be a char and you cannot cast a String which stores a number to be an int, float or double.
(True/False)
4.9/5
(38)
How many ways are there to test to see if two String variables, a and b, are equal to each other if we ignore their case (for instance, "aBCd" would be considered equal to "ABcd").
(Essay)
4.8/5
(45)
If x is a string, then x = new String("OH"); and x = "OH"; will accomplish the same thing.
(True/False)
4.8/5
(37)
Assume that a = "1", b = "2", y = 3 and z = 4. How do the following two statements differ?
System.out.println(a + b + y + z);
System.out.println(y + z + a + b);
(Essay)
4.8/5
(35)
Showing 21 - 40 of 77
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)