Java (Multimedia Approach) Ch 1-4

Beschreibung

C2 Java Programming Quiz am Java (Multimedia Approach) Ch 1-4, erstellt von johnrclark12 am 18/09/2014.
johnrclark12
Quiz von johnrclark12, aktualisiert more than 1 year ago
johnrclark12
Erstellt von johnrclark12 vor fast 10 Jahre
33
1

Zusammenfassung der Ressource

Frage 1

Frage
Machine language is a binary language composed of only zeros and ones
Antworten
  • True
  • False

Frage 2

Frage
A Java source file must have the following extension:
Antworten
  • .class
  • .c
  • .txt
  • .java

Frage 3

Frage
Java bytecode varies according to the type of processor used in the computer.
Antworten
  • True
  • False

Frage 4

Frage
Machine language is specific to the processor in a computer.
Antworten
  • True
  • False

Frage 5

Frage
The software development method is a framework used to:
Antworten
  • design an algorithm
  • develop a software product
  • maintain code
  • test code

Frage 6

Frage
Every program contains a particular sequence of operations referred to as
Antworten
  • the software development method.
  • a statement.
  • machine language.
  • an algorithm.

Frage 7

Frage
True or False? A processor can execute Java bytecode directly.
Antworten
  • True
  • False

Frage 8

Frage
Java is case-sensitive.
Antworten
  • True
  • False

Frage 9

Frage
Which of the following is a correct way to start a Java comment?
Antworten
  • */
  • "
  • /*
  • comment:
  • **

Frage 10

Frage
An object:
Antworten
  • is created using a constructor in a class.
  • has specific values assigned to its fields.
  • exists only while the program is running.
  • all of these answers are correct

Frage 11

Frage
An object of a class is also called an instance of that class.
Antworten
  • True
  • False

Frage 12

Frage
A class has values assigned to its fields whereas an object does not.
Antworten
  • True
  • False

Frage 13

Frage
An object reference variable:
Antworten
  • is an object.
  • holds the reference to an object.
  • references a primitive type.
  • is the name of a class.

Frage 14

Frage
A class:
Antworten
  • must contain at least one field.
  • is used to create an object.
  • has specific values assigned to its fields.
  • all of these are correct.

Frage 15

Frage
A constructor is a special method used to create an object.
Antworten
  • True
  • False

Frage 16

Frage
A string literal can span multiple lines.
Antworten
  • True
  • False

Frage 17

Frage
Suppose that you have a Golfer object sally. What is the proper way of calling the swing() method for sally? The declaration is: Golfer sally = new Golfer();
Antworten
  • sally.Golfer(swing);
  • none of these
  • swing().sally;
  • sally.swing();
  • Golfer.swing(sally);

Frage 18

Frage
Which of the following is a valid identifier?
Antworten
  • 1alpha
  • x1_123
  • $fifteen
  • num is

Frage 19

Frage
A variable can be initialized when it is declared.
Antworten
  • True
  • False

Frage 20

Frage
A widening conversion, in which a narrower type is converted to a wider type, takes place automatically.
Antworten
  • True
  • False

Frage 21

Frage
Which of the following is NOT a legal identifier for a variable?
Antworten
  • _gamma3
  • all of these are legal names
  • static
  • beta_2
  • alpha1

Frage 22

Frage
The drawString method in class Graphics2D is declared as follows: void drawString(String str, int x, int y) Assuming that some variables are declared as shown below, which calls to this method are valid? String s1 = " "; char c = 'x'; int x1 = 10, y1 = 20; double x2 = 20.5;
Antworten
  • drawString(c, x1, y1);
  • drawString(x2, s1, y1);
  • drawString(s1, x2, y1);
  • drawString(s1, x1, y1);

Frage 23

Frage
It is not necessary for a method to return a value.
Antworten
  • True
  • False

Frage 24

Frage
Before using a class in the java.lang package, it is necessary to import this class into the program.
Antworten
  • True
  • False

Frage 25

Frage
In order to read from the keyboard it is necessary to:
Antworten
  • use the System.in.readln() method
  • construct an object of the Keyboard class
  • use the System.our.println() method
  • none of these
  • construct an object of the Scanner class.

Frage 26

Frage
Which operation occurs first when the computer executes the statement below: int length = a - b * c % d--;
Antworten
  • c % d
  • a - b
  • d--
  • impossible to determine unless parentheses are used
  • b * c

Frage 27

Frage
True or False? If someInt is an integer and someFloat is a float the following statement is a correct assignment operation. someInt = someFloat;
Antworten
  • True
  • False

Frage 28

Frage
int GetHeight() is a method that returns the number of pixels in the column of an image.
Antworten
  • True
  • False

Frage 29

Frage
Which operation occurs first when the computer executes the statement below: int length = a % b - c * --d;
Antworten
  • c * --d
  • a % b
  • impossible to determine unless parentheses are used
  • --d
  • b - c

Frage 30

Frage
Color myColor = new Color(255, 0, 0); will create a Color object that is
Antworten
  • red
  • blue
  • green
  • something else
  • yellow

Frage 31

Frage
The Scanner class is part of the java.util package.
Antworten
  • True
  • False

Frage 32

Frage
Every "if" must match up with a corresponding "else".
Antworten
  • True
  • False

Frage 33

Frage
Which of the following is NOT a legal statement as written? Assume: double someDouble; int someInt; float someFloat; byte someByte; long someLong;
Antworten
  • all of these are legal
  • someLong = someFloat;
  • someLong = someByte;
  • someDouble = someInt;
  • someInt = someFloat;

Frage 34

Frage
What is the output of the following code segment for an input of 45? Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); if (x > 50) System.out.print("x is greater than 50."); else if (x > 30) System.out.print("x is greater than 30."); else if (x > 40) System.out.print("x is greater than 40.");
Antworten
  • x is greater than 40.
  • x is greater than 30.
  • x is greater than 30. x is greater than 40.
  • x is greater than 50.

Frage 35

Frage
The code below is designed so that ONLY one shape will be displayed (assume the rest of the program has been developed): if (magicShape == 0) { // magicShape is 0, draw and color a rectangle Rectangle2D.Float shape = new Rectangle2D.Float(x, y, w1, h1); dk.fill(shape); } else if (magicShape == 1) { // magicShape is 1, draw and color an ellipse Ellipse2D.Float shape1 = new Ellipse2D.Float(x, y, w1, h1); dk.fill(shape1); } else if (magicShape == 2) { // magicShape is 2, draw and color a circle Ellipse2D.Float shape2 = new Ellipse2D.Float(x, y, w2, h2); dk.fill(shape2); } else { // magicShape is 3, draw a square Rectangle2D.Float shape3 = new Rectangle2D.Float(x, y, w2, h2); dk.draw(shape3); }
Antworten
  • True
  • False

Frage 36

Frage
It is reasonable to use the switch statement to check the value of a String object.
Antworten
  • True
  • False

Frage 37

Frage
What is the output of the following code segment for an input of 2? System.out.print("Enter x:"); Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); switch(x) { case 1: System.out.print("1"); case 2: System.out.print("2"); case 3: System.out.print("3"); }
Antworten
  • 23
  • 3
  • 2
  • 12

Frage 38

Frage
How many times will the loop below go through the body of the loop (assume all variables are declared appropriately)? int numTimes = 5; while (numTimes >= 0) { { // do something in the loop numTimes++; }
Antworten
  • 6
  • 5
  • it will go through the loop forever
  • 0

Frage 39

Frage
The do - while loop will always go through at least one iteration (as long as there is no break; statement)
Antworten
  • True
  • False

Frage 40

Frage
True or False? Logical operators can only have boolean operands.
Antworten
  • True
  • False

Frage 41

Frage
In the boolean expression a > b && c < d || e == f which operation will be evaluated first?
Antworten
  • <
  • &&
  • >
  • ||
  • ==

Frage 42

Frage
Every while loop must execute (iterate) at least one time.
Antworten
  • True
  • False

Frage 43

Frage
The continue; statement will make execution skip to the bottom of the loop and exit the loop entirely.
Antworten
  • True
  • False

Frage 44

Frage
What will be printed by the following loop? for (int i = 0; i < 6; i++) { if (i % 3 == 0) { System.out.print(i); } }
Antworten
  • none of these
  • 36
  • 012345
  • 03
  • 036

Frage 45

Frage
Which of the following is used to express the logical operation "OR"?
Antworten
  • !!
  • none of these
  • ||
  • ??
  • &&

Frage 46

Frage
True or False? Evaluate the following boolean condition: num1 = 2; num2 = 1; bool = !(num1--==num2);
Antworten
  • True
  • False

Frage 47

Frage
The break; statement is only used with the switch - case statement.
Antworten
  • True
  • False

Frage 48

Frage
I want to print the message "uncomfortable" when the temperature is outside of the range of 60 to 80 degrees. Which condition will properly test for this situation?
Antworten
  • (60 < temperature || >80)
  • (60 > temperature > 80)
  • (60 > temperature && temperature > 80)
  • none of these
  • (60 > temperature || temperature > 80)
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

JAVA basics
Joseph Jimenez
Berufe der Zukunft
JohannesK
Teil B, Kapitel 1.3, Handelsregister
Stefan Kurtenbach
Magnetismus
Peter Kasebacher
Psych
Mona Les
Themenübersicht (Analysis)
Honolulu
KPOL-Fragen
Lisa-Maria Hauschild
Unsere Erde - Sonnensystem, Klima, Erdschichten etc.
Laura Overhoff
Sturm und Drang & Empfindsamkeit
Julia Schaffhirt
Bildungswissenschaft
Yvonne Heitland
GPSY ALPS
Malte Ni