Deck 2: Java Fundamentals
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/52
العب
ملء الشاشة (f)
Deck 2: Java Fundamentals
1
Which of the following is not a valid Java comment?
A) /** Comment one */
B) */ Comment two /*
C) // Comment three
D) /* Comment four */
A) /** Comment one */
B) */ Comment two /*
C) // Comment three
D) /* Comment four */
B
2
Both character and string literals can be assigned to a char variable.
False
3
Java is not case sensitive.
False
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
A) single quotes, double quotes
B) double quotes, single quotes
C) single quotes, single quotes
D) double quotes, double quotes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
5
The Java API provides a class named Math that contains numerous methods which are useful for performing complex mathematical operations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
6
Programming style includes techniques for consistently putting spaces and indentation in a program to help create visual cues.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
7
A Java source file must be saved with the extension
A) .java
B) .javac
C) .src
D) .class
A) .java
B) .javac
C) .src
D) .class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following would contain the translated Java byte code for a program named Demo?
A) Demo.java
B) Demo.code
C) Demo.class
D) Demo.byte
A) Demo.java
B) Demo.code
C) Demo.class
D) Demo.byte
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
9
A variable's scope is the part of the program that has access to that variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
10
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
A) a comment
B) a class definition
C) a System.out.println(); statement
D) a variable declaration
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
11
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
A) a literal
B) an operator
C) a constant
D) a variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
12
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
13
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) a literal
B) an assignment statement
C) an operator
D) a variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
14
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
15
To compile a program named First you would use which of the following commands?
A) java First.java
B) javac First
C) javac First.java
D) compile First.javac
A) java First.java
B) javac First
C) javac First.java
D) compile First.javac
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
16
If the compiler encounters a statement that uses a variable before the variable is declared, an error will result.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
17
The System.out.printf method allows you to format output in a variety of ways.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
18
Class names and key words are examples of variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
19
A Java program will not compile unless it contains the correct line numbers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
20
Named constants are initialized with a value and that value cannot change during the execution of the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
21
What is the result of the following expression?
10 + 5 * 3 - 20
A) -5
B) -50
C) 5
D) 25
10 + 5 * 3 - 20
A) -5
B) -50
C) 5
D) 25
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
22
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
int x = 5, y = 28;
Float z;
Z = (float) (y / x);
A) 5.6
B) 3.0
C) 5.0
D) 5.60
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
23
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);
A) System.out.println("Hello, world");
B) System Print = "Hello, world";
C) SystemOutPrintln('Hello, world');
D) system.out.println(Hello, world);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which Scanner class method reads a String?
A) nextLine
B) charAt
C) nextString
D) getLine
A) nextLine
B) charAt
C) nextString
D) getLine
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
25
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 =y;
C) x = (float)y;
D) x = y;
A) x = float y;
B) x =
C) x = (float)y;
D) x = y;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
26
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
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
27
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
A) evaluating conditions that are either true or false
B) working with small integers
C) working with very large integers
D) evaluating scientific notation
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
28
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;
A) double r = 9.4632E15;
B) double r = 9.4632e15;
C) double r = 2.9X106;
D) double r = 326.75;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
29
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
30
In Java, __________ must be declared before they can be used.
A) variables
B) literals
C) key words
D) comments
A) variables
B) literals
C) key words
D) comments
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
31
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
int x = 4, y = 33;
Double z;
Z = (double) (y / x);
A) 8.25
B) 4
C) 0
D) 8.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
32
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
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
33
The primitive data types only allow a(n) __________ to hold a single value.
A) class
B) literal
C) object
D) variable
A) class
B) literal
C) object
D) variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
34
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
A) "name"
B) the memory address where "John Doe" is located
C) the memory address where name is located
D) John Doe
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
35
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);
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
36
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
A) -128 to + 127
B) true or false
C) -2,147,483,648 to +2,147,483,647
D) -32,768 to +32,767
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
37
If the following Java statements are executed, what will be displayed? System.out.println("The top three winners are\n");
System.out.print("Jody, the Giant\n");
System.out.print("Buffy, the Barbarian");
System.out.println("Adelle, the Alligator");
A) The top three winners are
Jody, the Giant
Buffy, the Barbarian
Adelle, the Alligator
B) The top three winners are Jody, the Giant\nBuffy, the BarbarianAdelle, and the Albino
C) The top three winners are
Jody, the Giant\nBuffy, the BarbarianAdelle, the Alligator
D) The top three winners are
Jody, the Giant
Buffy, the BarbarianAdelle, the Alligator
System.out.print("Jody, the Giant\n");
System.out.print("Buffy, the Barbarian");
System.out.println("Adelle, the Alligator");
A) The top three winners are
Jody, the Giant
Buffy, the Barbarian
Adelle, the Alligator
B) The top three winners are Jody, the Giant\nBuffy, the BarbarianAdelle, and the Albino
C) The top three winners are
Jody, the Giant\nBuffy, the BarbarianAdelle, the Alligator
D) The top three winners are
Jody, the Giant
Buffy, the BarbarianAdelle, the Alligator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
38
What is the result of the following expression?
17 % 3 * 2 - 12 + 15
A) 105
B) 12
C) 7
D) 8
17 % 3 * 2 - 12 + 15
A) 105
B) 12
C) 7
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
39
Variables are classified according to their
A) names
B) values
C) locations
D) data types
A) names
B) values
C) locations
D) data types
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
40
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
41
Which of the following is not a primitive data type?
A) short
B) long
C) float
D) string
A) short
B) long
C) float
D) string
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
42
A value that is written into the code of a program is a(n) __________.
A) literal
B) assignment statement
C) variable
D) operator
A) literal
B) assignment statement
C) variable
D) operator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
43
What will be displayed as a result of executing the following code?
public class test
{
Public static void main(String[ ] args)
{
Int value1 = 9;
System.out.println(value1);
Int value2 = 45;
System.out.println(value2);
System.out.println(value3);
Value = 16;
}
}
A) 9
45
16
B) 94516
C) 9 45 16
D) Nothing. This is an error
public class test
{
Public static void main(String[ ] args)
{
Int value1 = 9;
System.out.println(value1);
Int value2 = 45;
System.out.println(value2);
System.out.println(value3);
Value = 16;
}
}
A) 9
45
16
B) 94516
C) 9 45 16
D) Nothing. This is an error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
44
If x has been declared an int, which of the following statements is invalid?
A) x = 0;
B) x = -59832;
C) x = 1,000;
D) x = 592
A) x = 0;
B) x = -59832;
C) x = 1,000;
D) x = 592
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
45
Every Java application program must have
A) a class named MAIN
B) a method named main
C) at least two data types
D) integer variables
A) a class named MAIN
B) a method named main
C) at least two data types
D) integer variables
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
46
What will be displayed as a result of executing the following code? int x = 6;
String msg = "I am enjoying this class.";
String msg1 = msg.toUpperCase();
String msg2 = msg.toLowerCase();
Char ltr = msg.charAt(x);
Int strSize = msg.length();
System.out.println(msg);
System.out.println(msg1);
System.out.println(msg2);
System.out.println("Character at index x = " + ltr);
System.out.println("msg has " + strSize + "characters.");
A) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 24 characters.
B) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 25 characters.
C) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 24 characters.
D) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 25characters.
String msg = "I am enjoying this class.";
String msg1 = msg.toUpperCase();
String msg2 = msg.toLowerCase();
Char ltr = msg.charAt(x);
Int strSize = msg.length();
System.out.println(msg);
System.out.println(msg1);
System.out.println(msg2);
System.out.println("Character at index x = " + ltr);
System.out.println("msg has " + strSize + "characters.");
A) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 24 characters.
B) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 25 characters.
C) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 24 characters.
D) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 25characters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
47
To display the output on the next line, you can use the println method or use the __________ escape sequence in the print method.
A) \n
B) \r
C) \t
D) \b
A) \n
B) \r
C) \t
D) \b
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
48
Which of the following is not a rule that must be followed when naming identifiers?
A) The first character must be one of the letters a-z, A-Z, and underscore or a dollar sign.
B) Identifiers can contain spaces.
C) Uppercase and lowercase characters are distinct.
D) After the first character, you may use the letters a-z, A-Z, the underscore, a dollar sign, or digits 0-9.
A) The first character must be one of the letters a-z, A-Z, and underscore or a dollar sign.
B) Identifiers can contain spaces.
C) Uppercase and lowercase characters are distinct.
D) After the first character, you may use the letters a-z, A-Z, the underscore, a dollar sign, or digits 0-9.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
49
Which of the following cannot be used as identifiers in Java?
A) variable names
B) class names
C) key words
D) objects
A) variable names
B) class names
C) key words
D) objects
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
50
What would be printed out as a result of the following code? System.out.println("The quick brown fox" +
"jumped over the \n"
"slow moving hen.");
A) The quick brown fox jumped over the \nslow moving hen.
B) The quick brown fox jumped over the
Slow moving hen.
C) The quick brown fox
Jumped over the
Slow moving hen.
D) Nothing - this is an error
"jumped over the \n"
"slow moving hen.");
A) The quick brown fox jumped over the \nslow moving hen.
B) The quick brown fox jumped over the
Slow moving hen.
C) The quick brown fox
Jumped over the
Slow moving hen.
D) Nothing - this is an error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
51
Which of the following is valid?
A) float y;
Y = 54.9;
B) float y;
Double z;
Z = 934.21;
Y = z;
C) float w;
W = 1.0f;
D) float v;
V = 1.0
A) float y;
Y = 54.9;
B) float y;
Double z;
Z = 934.21;
Y = z;
C) float w;
W = 1.0f;
D) float v;
V = 1.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
52
When the + operator is used with strings, it is known as the
A) assignment operator
B) string concatenation operator
C) addition operator
D) combines assignment operator
A) assignment operator
B) string concatenation operator
C) addition operator
D) combines assignment operator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck