Deck 2: Java Fundamentals

ملء الشاشة (f)
exit full mode
سؤال
Both character and string literals can be assigned to a char variable.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which of the following is a value that is written into the code of a program?

A) a literal
B) an assignment statement
C) an operator
D) a variable
سؤال
Which of the following is a named storage location in the computer's memory?

A) a literal
B) an operator
C) a constant
D) a variable
سؤال
Character literals are enclosed in __________ and string literals are enclosed in __________.

A) single quotes, double quotes
B) double quotes, single quotes
C) single quotes, single quotes
D) double quotes, double quotes
سؤال
When you call one of the Scanner class's methods to read a primitive value, such as nextInt or nextDouble , and then call the nextLine method to read a string, an annoying and hard-to-find problem can occur.
سؤال
What is the result of the following expression?
10 + 5 * 3 - 20

A) -5
B) -50
C) 5
D) 25
سؤال
In the following Java statement, what value is stored in the variable name?
String name = "John Doe";

A) "name"

B) the memory address where "John Doe" is located
C) the memory address where name is located
D) John Doe
سؤال
The System.out.printf method allows you to format output in a variety of ways.
سؤال
The Java API provides a class named Math that contains numerous methods which are useful for performing complex mathematical operations.
سؤال
Unlike a console program, a program that uses the JOptionPane does not automatically stop executing when the end of the main method is reached.
سؤال
Which of the following is not a rule that must be followed when naming identifiers?

A) After the first character, you may use the letters a-z, A-Z, an underscore, a dollar sign, or the digits 0-9.
B) Identifiers can contain spaces.
C) Uppercase and lowercase characters are distinct.
D) The first character must be one of the letters a-z, A-Z, an underscore, or a dollar sign.
سؤال
Programming style includes techniques for consistently putting spaces and indentation in a program to help create visual cues.
سؤال
Which of the following is not a valid Java comment?

A) /** Comment one */
B) */ Comment two /*
C) // Comment three
D) /* Comment four */
سؤال
Variables are classified according to their

A) names
B) values
C) locations
D) data types
سؤال
What is the result of the following expression?
17 % 3 * 2 - 12 + 15

A) 105
B) 12
C) 7
D) 8
سؤال
Named constants are initialized with a value and that value cannot change during the execution of the program.
سؤال
If you use a flag in a format specifier, you must write the flag before the field width and the precision.
سؤال
A Java source file must be saved with the extension

A) .java
B) .javac
C) .src
D) .class
سؤال
A message dialog is a quick and simple way to ask the user to enter data.
سؤال
A variable's scope is the part of the program that has access to that variable.
سؤال
What would be displayed as a result of executing the following code?
int x = 578;
System.out.print("There are " +
X + 5 + "\n" +
"hens in the hen house.");

A) There are 583
Hens in the hen house.
B) There are 5785
Hens in the hen house.
C) There are x5\nhens in the hen house.
D) There are 5785 hens in the hen house.
سؤال
The boolean data type may contain which of the following range of values?

A) -128 to + 127
B) true or false
C) -2,147,483,648 to +2,147,483,647
D) -32,768 to +32,767
سؤال
The __________ method is used to display a message dialog.

A) showMessageDialog
B) messageDialog
C) messageDialogShow
D) showDialog
سؤال
Variables of the boolean data type are useful for

A) evaluating conditions that are either true or false
B) working with small integers
C) working with very large integers
D) evaluating scientific notation
سؤال
What is the value of z after the following code is executed?
int x = 5, y = 28;
Float z;
Z = (float) (y / x);

A) 5.6
B) 3.0
C) 5.0
D) 5.60
سؤال
If you want to use the System.out.printf method to print a string argument , use the __________ format specifier.

A) % d
B) %b
C) %f
D) % s
سؤال
Which of the following statements correctly creates a Scanner object for keyboard input?

A) Scanner kbd = new Scanner(System.keyboard);
B) Scanner keyboard = new Scanner(System.in);
C) Scanner keyboard(System.in);
D) Keyboard scanner = new Keyboard(System.in);
سؤال
What would be displayed as a result of executing the following code?
int x = 15, y = 20, z = 32;
X += 12;
Y /= 6;
Z -= 14;
System.out.println("x = " + x +
", y = " + y +
", z = " + z);

A) x = 27, y = 3.333, z = 18
B) x = 27, y = 2, z = 18
C) x = 37, y = -14, z = 4
D) x = 27, y = 3, z = 18
سؤال
The simplest way to use the System.out.printf method is

A) with a format string and one format specifier
B) with only a format string and no additional arguments
C) with a format string and one or more format specifiers
D) with only one format specifier and no format string
سؤال
A Java program must have at least one of the following:

A) a comment
B) a class definition
C) a System.out.println(); statement
D) a variable declaration
سؤال
What output will be displayed as a result of executing the following code?
int x = 5, y = 20;
X += 32;
Y /= 4;
System.out.println("x = " + x + ", y = " + y);

A) x = 160, y = 80
B) x = 32, y = 4
C) x = 37, y = 5
D) x = 9, y = 52
سؤال
What would be displayed as a result of executing the following code?
final int x = 22, y = 4;
Y += x;
System.out.println("x = " + x + ", y = " + y)

A) x = 22, y = 26
B) x = 22, y = 4
C) x = 22, y = 88

D) Nothing. There is an error in the code.
سؤال
A(n) __________ is a dialog box that prompts the user for input.

A) input box
B) user prompt
C) adaptive dialog
D) input dialog
سؤال
What is the value of z after the following statements have been executed?
int x = 4, y = 33;
Double z;
Z = (double) (y / x);

A) 8.25
B) 4
C) 0
D) 8.0
سؤال
Which statement tells the compiler where to find the JOptionPane class and makes it available to your program?

A) import javax.swing.JOptionPane;
B) import Java.Swing.JOptionPane;
C) import JOptionPane;
D) import javax.JOptionPane;
سؤال
Which of the following statements will correctly convert the data type, if x is a float and y is a double?

A) x = float y;
B) x = <float>y;
C) x = (float)y;
D) x = y;
سؤال
To print "Hello, world" on the monitor, which of the following Java statements should be used?

A) System.out.println("Hello, world");
B) System Print = "Hello, world";
C) SystemOutPrintln('Hello, world');
D) system.out.println(Hello, world);
سؤال
The primitive data types only allow a(n) __________ to hold a single value.

A) class
B) literal
C) object
D) variable
سؤال
Which of the following statements is invalid?

A) double r = 9.4632E15;
B) double r = 9.4632e15;
C) double r = 2.9X106;
D) double r = 326.75;
سؤال
Which Scanner class method reads a String?

A) nextLine
B) charAt
C) nextString
D) getLine
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 2: Java Fundamentals
1
Both character and string literals can be assigned to a char variable.
False
2
Which of the following is a value that is written into the code of a program?

A) a literal
B) an assignment statement
C) an operator
D) a variable
A
3
Which of the following is a named storage location in the computer's memory?

A) a literal
B) an operator
C) a constant
D) a variable
D
4
Character literals are enclosed in __________ and string literals are enclosed in __________.

A) single quotes, double quotes
B) double quotes, single quotes
C) single quotes, single quotes
D) double quotes, double quotes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
When you call one of the Scanner class's methods to read a primitive value, such as nextInt or nextDouble , and then call the nextLine method to read a string, an annoying and hard-to-find problem can occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
What is the result of the following expression?
10 + 5 * 3 - 20

A) -5
B) -50
C) 5
D) 25
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
In the following Java statement, what value is stored in the variable name?
String name = "John Doe";

A) "name"

B) the memory address where "John Doe" is located
C) the memory address where name is located
D) John Doe
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
The System.out.printf method allows you to format output in a variety of ways.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
The Java API provides a class named Math that contains numerous methods which are useful for performing complex mathematical operations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
Unlike a console program, a program that uses the JOptionPane does not automatically stop executing when the end of the main method is reached.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following is not a rule that must be followed when naming identifiers?

A) After the first character, you may use the letters a-z, A-Z, an underscore, a dollar sign, or the digits 0-9.
B) Identifiers can contain spaces.
C) Uppercase and lowercase characters are distinct.
D) The first character must be one of the letters a-z, A-Z, an underscore, or a dollar sign.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
Programming style includes techniques for consistently putting spaces and indentation in a program to help create visual cues.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following is not a valid Java comment?

A) /** Comment one */
B) */ Comment two /*
C) // Comment three
D) /* Comment four */
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
Variables are classified according to their

A) names
B) values
C) locations
D) data types
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
What is the result of the following expression?
17 % 3 * 2 - 12 + 15

A) 105
B) 12
C) 7
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
Named constants are initialized with a value and that value cannot change during the execution of the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
If you use a flag in a format specifier, you must write the flag before the field width and the precision.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
A Java source file must be saved with the extension

A) .java
B) .javac
C) .src
D) .class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
A message dialog is a quick and simple way to ask the user to enter data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
A variable's scope is the part of the program that has access to that variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
What would be displayed as a result of executing the following code?
int x = 578;
System.out.print("There are " +
X + 5 + "\n" +
"hens in the hen house.");

A) There are 583
Hens in the hen house.
B) There are 5785
Hens in the hen house.
C) There are x5\nhens in the hen house.
D) There are 5785 hens in the hen house.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
The boolean data type may contain which of the following range of values?

A) -128 to + 127
B) true or false
C) -2,147,483,648 to +2,147,483,647
D) -32,768 to +32,767
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
The __________ method is used to display a message dialog.

A) showMessageDialog
B) messageDialog
C) messageDialogShow
D) showDialog
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
Variables of the boolean data type are useful for

A) evaluating conditions that are either true or false
B) working with small integers
C) working with very large integers
D) evaluating scientific notation
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
What is the value of z after the following code is executed?
int x = 5, y = 28;
Float z;
Z = (float) (y / x);

A) 5.6
B) 3.0
C) 5.0
D) 5.60
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
If you want to use the System.out.printf method to print a string argument , use the __________ format specifier.

A) % d
B) %b
C) %f
D) % s
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which of the following statements correctly creates a Scanner object for keyboard input?

A) Scanner kbd = new Scanner(System.keyboard);
B) Scanner keyboard = new Scanner(System.in);
C) Scanner keyboard(System.in);
D) Keyboard scanner = new Keyboard(System.in);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
What would be displayed as a result of executing the following code?
int x = 15, y = 20, z = 32;
X += 12;
Y /= 6;
Z -= 14;
System.out.println("x = " + x +
", y = " + y +
", z = " + z);

A) x = 27, y = 3.333, z = 18
B) x = 27, y = 2, z = 18
C) x = 37, y = -14, z = 4
D) x = 27, y = 3, z = 18
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
The simplest way to use the System.out.printf method is

A) with a format string and one format specifier
B) with only a format string and no additional arguments
C) with a format string and one or more format specifiers
D) with only one format specifier and no format string
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
A Java program must have at least one of the following:

A) a comment
B) a class definition
C) a System.out.println(); statement
D) a variable declaration
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
What output will be displayed as a result of executing the following code?
int x = 5, y = 20;
X += 32;
Y /= 4;
System.out.println("x = " + x + ", y = " + y);

A) x = 160, y = 80
B) x = 32, y = 4
C) x = 37, y = 5
D) x = 9, y = 52
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
What would be displayed as a result of executing the following code?
final int x = 22, y = 4;
Y += x;
System.out.println("x = " + x + ", y = " + y)

A) x = 22, y = 26
B) x = 22, y = 4
C) x = 22, y = 88

D) Nothing. There is an error in the code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
A(n) __________ is a dialog box that prompts the user for input.

A) input box
B) user prompt
C) adaptive dialog
D) input dialog
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
What is the value of z after the following statements have been executed?
int x = 4, y = 33;
Double z;
Z = (double) (y / x);

A) 8.25
B) 4
C) 0
D) 8.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
Which statement tells the compiler where to find the JOptionPane class and makes it available to your program?

A) import javax.swing.JOptionPane;
B) import Java.Swing.JOptionPane;
C) import JOptionPane;
D) import javax.JOptionPane;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which of the following statements will correctly convert the data type, if x is a float and y is a double?

A) x = float y;
B) x = <float>y;
C) x = (float)y;
D) x = y;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
To print "Hello, world" on the monitor, which of the following Java statements should be used?

A) System.out.println("Hello, world");
B) System Print = "Hello, world";
C) SystemOutPrintln('Hello, world');
D) system.out.println(Hello, world);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
The primitive data types only allow a(n) __________ to hold a single value.

A) class
B) literal
C) object
D) variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
Which of the following statements is invalid?

A) double r = 9.4632E15;
B) double r = 9.4632e15;
C) double r = 2.9X106;
D) double r = 326.75;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
Which Scanner class method reads a String?

A) nextLine
B) charAt
C) nextString
D) getLine
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.