Java (Multimedia Approach) Ch 1-4

Descrição

C2 Java Programming Quiz sobre Java (Multimedia Approach) Ch 1-4, criado por johnrclark12 em 18-09-2014.
johnrclark12
Quiz por johnrclark12, atualizado more than 1 year ago
johnrclark12
Criado por johnrclark12 aproximadamente 10 anos atrás
34
1

Resumo de Recurso

Questão 1

Questão
Machine language is a binary language composed of only zeros and ones
Responda
  • True
  • False

Questão 2

Questão
A Java source file must have the following extension:
Responda
  • .class
  • .c
  • .txt
  • .java

Questão 3

Questão
Java bytecode varies according to the type of processor used in the computer.
Responda
  • True
  • False

Questão 4

Questão
Machine language is specific to the processor in a computer.
Responda
  • True
  • False

Questão 5

Questão
The software development method is a framework used to:
Responda
  • design an algorithm
  • develop a software product
  • maintain code
  • test code

Questão 6

Questão
Every program contains a particular sequence of operations referred to as
Responda
  • the software development method.
  • a statement.
  • machine language.
  • an algorithm.

Questão 7

Questão
True or False? A processor can execute Java bytecode directly.
Responda
  • True
  • False

Questão 8

Questão
Java is case-sensitive.
Responda
  • True
  • False

Questão 9

Questão
Which of the following is a correct way to start a Java comment?
Responda
  • */
  • "
  • /*
  • comment:
  • **

Questão 10

Questão
An object:
Responda
  • 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

Questão 11

Questão
An object of a class is also called an instance of that class.
Responda
  • True
  • False

Questão 12

Questão
A class has values assigned to its fields whereas an object does not.
Responda
  • True
  • False

Questão 13

Questão
An object reference variable:
Responda
  • is an object.
  • holds the reference to an object.
  • references a primitive type.
  • is the name of a class.

Questão 14

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

Questão 15

Questão
A constructor is a special method used to create an object.
Responda
  • True
  • False

Questão 16

Questão
A string literal can span multiple lines.
Responda
  • True
  • False

Questão 17

Questão
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();
Responda
  • sally.Golfer(swing);
  • none of these
  • swing().sally;
  • sally.swing();
  • Golfer.swing(sally);

Questão 18

Questão
Which of the following is a valid identifier?
Responda
  • 1alpha
  • x1_123
  • $fifteen
  • num is

Questão 19

Questão
A variable can be initialized when it is declared.
Responda
  • True
  • False

Questão 20

Questão
A widening conversion, in which a narrower type is converted to a wider type, takes place automatically.
Responda
  • True
  • False

Questão 21

Questão
Which of the following is NOT a legal identifier for a variable?
Responda
  • _gamma3
  • all of these are legal names
  • static
  • beta_2
  • alpha1

Questão 22

Questão
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;
Responda
  • drawString(c, x1, y1);
  • drawString(x2, s1, y1);
  • drawString(s1, x2, y1);
  • drawString(s1, x1, y1);

Questão 23

Questão
It is not necessary for a method to return a value.
Responda
  • True
  • False

Questão 24

Questão
Before using a class in the java.lang package, it is necessary to import this class into the program.
Responda
  • True
  • False

Questão 25

Questão
In order to read from the keyboard it is necessary to:
Responda
  • 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.

Questão 26

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

Questão 27

Questão
True or False? If someInt is an integer and someFloat is a float the following statement is a correct assignment operation. someInt = someFloat;
Responda
  • True
  • False

Questão 28

Questão
int GetHeight() is a method that returns the number of pixels in the column of an image.
Responda
  • True
  • False

Questão 29

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

Questão 30

Questão
Color myColor = new Color(255, 0, 0); will create a Color object that is
Responda
  • red
  • blue
  • green
  • something else
  • yellow

Questão 31

Questão
The Scanner class is part of the java.util package.
Responda
  • True
  • False

Questão 32

Questão
Every "if" must match up with a corresponding "else".
Responda
  • True
  • False

Questão 33

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

Questão 34

Questão
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.");
Responda
  • 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.

Questão 35

Questão
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); }
Responda
  • True
  • False

Questão 36

Questão
It is reasonable to use the switch statement to check the value of a String object.
Responda
  • True
  • False

Questão 37

Questão
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"); }
Responda
  • 23
  • 3
  • 2
  • 12

Questão 38

Questão
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++; }
Responda
  • 6
  • 5
  • it will go through the loop forever
  • 0

Questão 39

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

Questão 40

Questão
True or False? Logical operators can only have boolean operands.
Responda
  • True
  • False

Questão 41

Questão
In the boolean expression a > b && c < d || e == f which operation will be evaluated first?
Responda
  • <
  • &&
  • >
  • ||
  • ==

Questão 42

Questão
Every while loop must execute (iterate) at least one time.
Responda
  • True
  • False

Questão 43

Questão
The continue; statement will make execution skip to the bottom of the loop and exit the loop entirely.
Responda
  • True
  • False

Questão 44

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

Questão 45

Questão
Which of the following is used to express the logical operation "OR"?
Responda
  • !!
  • none of these
  • ||
  • ??
  • &&

Questão 46

Questão
True or False? Evaluate the following boolean condition: num1 = 2; num2 = 1; bool = !(num1--==num2);
Responda
  • True
  • False

Questão 47

Questão
The break; statement is only used with the switch - case statement.
Responda
  • True
  • False

Questão 48

Questão
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?
Responda
  • (60 < temperature || >80)
  • (60 > temperature > 80)
  • (60 > temperature && temperature > 80)
  • none of these
  • (60 > temperature || temperature > 80)

Semelhante

JAVA basics
Joseph Jimenez
Atualidades Brasil e Mundo
Alessandra S.
Técnico em Segurança do Trabalho
Cleber Scarduell
CONTABILIDADE GERAL
MJPD
GESTAO ESTRATÉGICA DE RH
Matheus Miranda
Fontes e princípios do direito do trabalho
Natthan Réryson
Mapa Mental de GoConqr
GoConqr suporte .
Direito Constitucional Esquematizado - Pedro Lenza - Capítulo 3
Anaximandro Martins Leão
Mapa Mental - Como Criar um Mapa Mental
Adelaide Silva A
Direito Constitucional e Administrativo
Maria José
Geografia - Cartografia
Jessica Caroline de Macedo