Deck 4: Fundamental Data Types

ملء الشاشة (f)
exit full mode
سؤال
What is the output of the following code snippet? public static void main(String[] args)
{
Double a;
A = Math.sqrt(9.0) + Math.sqrt(16.0);
System.out.println(a);
}

A) 25.0
B) 337.0
C) 7.0
D) 19.0
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
What will be the value stored in the variable x after the execution of the following code snippet?
Int a = 10;
Int b = 20;
Int c = 2;
Int x = b / a /*c*/;

A) 1
B) 2
C) 4
D) The code has a syntax error
سؤال
Which of the following statements is correct about constants?

A) Constants are written using capital letters because the compiler ignores constants declared in small letters.
B) The data stored inside a constant can be changed using an assignment statement.
C) You can make a variable constant by using the final reserved word when declaring it.
D) Constant variables can only be changed through the Math library.
سؤال
What is the result of the following expression? double d = 2.5 + 4 * -1.5 - (2.5 + 4) * -1.5;

A) 24.375
B) 6.25
C) 12.375
D) 6
سؤال
What is the result of the following code snippet? public static void main(String[] args)
{
Double circleRadius;
Double circleVolume = 22 / 7 * circleRadius * circleRadius;
System.out.println(circleVolume);
}

A) 0
B) 3.14
C) 6.28
D) compile-time error
سؤال
What is wrong with the following code snippet?
Int average;
Average = 78A;

A) The average variable is never initialized.
B) The data type for the average variable is not specified.
C) The average variable is never assigned a value.
D) The average variable is assigned a non-numeric value.
سؤال
Which one of the following operators computes the remainder of an integer division?

A) /
B) %
C) \
D) !
سؤال
) What are the values of num1 and num2 after this snippet executes? double num1 = 4.20;
Double num2 = num1 * 10 + 5.0;

A) num1 = 4.20 and num2 = 42.0
B) num1 = 4.20 and num2 = 47.0
C) num1 = 42.0 and num2 = 42.0
D) num1 = 42.0 and num2 = 47.0
سؤال
What is wrong with the following code?
Int count = 2000 * 3000 * 4000;

A) Wrong data type
B) Variable is undefined
C) Integer overflow
D) Illegal expression
سؤال
Which of the following guidelines will make code more explanatory for others?

A) Use more statements in source code.
B) Add comments to source code.
C) Avoid usage of complex calculations in source code.
D) Always enclose the statements in curly braces in source code.
سؤال
Assuming that the user inputs a value of 25 for the price and 10 for the discount rate in the following code snippet, what is the output? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the price: ");
Double price = in.nextDouble();
System.out.print("Enter the discount rate: ");
Double discount = in.nextDouble();
System.out.println("The new price is " +
Price - price * (discount / 100.0));
}

A) The new price is 25
B) The new price is 15
C) The new price is 22.5
D) The new price is 20.0
سؤال
What is the output of the following code snippet? public static void main(String[] args)
{
Int value = 25;
Value = value * 2;
Value--;
System.out.println(value);
}

A) 25
B) 50
C) 49
D) 26
سؤال
Which of the following statements with comments is(are) valid?
I) int cnt = 0; /* Set count to 0
II) int cnt = 0; /* Set count to 0 */
III) int cnt = 0; // Set count to 0

A) Only I is valid
B) I and II are valid
C) II and III are valid
D) Only III is valid
سؤال
What is wrong with the following code snippet? public class Area
{
Public static void main(String[] args)
{
Int width = 10;
Height = 20.00;
System.out.println("area = " + (width * height));
}
}

A) The code snippet uses an uninitialized variable.
B) The code snippet uses an undeclared variable.
C) The code snippet attempts to assign a decimal value to an integer variable.
D) The code snippet attempts to add a number to a string variable.
سؤال
What is the value of Math.pow(3, 2)?

A) 6.0
B) 9.0
C) 8.0
D) 5.0
سؤال
What is the output of the following code snippet? public static void main(String[] args)
{
Int value = 3;
Value++;
System.out.println(value);
}

A) 2
B) 3
C) 4
D) No output due to syntax error
سؤال
Which of the following options declares a float variable?

A) Float age;
B) flt age;
C) float age;
D) age: float;
سؤال
What is the value inside the value variable at the end of the given code snippet? public static void main(String[] args)
{
Int value = 3;
Value = value - 2 * value;
Value++;
}

A) -2
B) 0
C) 2
D) 4
سؤال
Which one of the following variables is assigned with valid literals?

A) int salary = 0;
Salary = 5000.50;
B) int salary1 = 0;
Salary1 = 1.2E6;
C) double salary2 = 0;
Salary2 = 2.96E-2;
D) long salary3 = 0;
Salary3 = 1E-6;
سؤال
What will be the value inside the variables a and b after the given set of assignments?
Int a = 20;
Int b = 10;
A = (a +

A) a = 15, b = 16
B) / 2; b = a;
A++;
B) a = 16, b = 16
C) a = 16, b = 15
D) a = 15, b = 15
سؤال
How do you compute the length of the string str?

A) length(str)
B) length.str
C) str.length
D) str.length()
سؤال
Assuming that the user enters 45 and 62 as inputs for n1 and n2, respectively, what is the output of the following code snippet? public static void main(String[] args)
{
System.out.print("Enter a number: ");
Scanner in = new Scanner(System.in);
String n1 = in.next();
System.out.print("Enter another number: ");
String n2 = in.next();
String result = n1 + n2;
System.out.print(result);
}

A) 46
B) 4662
C) 107
D) 4562
سؤال
Which is the Java equivalent of the following mathematical expression? c = √(a2 + b2)

A) c = Math.sqrt(a * 2 + b * 2);
B) c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C) c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
D) c = Math.sqrt(Math.pow(a, 2)) + Math.sqrt(Math.pow(b, 2));
سؤال
Which operator is used to concatenate two or more strings?

A) +
B) %
C) &
D) ^
سؤال
Which one of the following statements can be used to extract the last five characters from any string variable str?

A) str.substring(str.length() - 5, str.length())
B) str.substring(5, 5)
C) str.substring(str.length() - 4, 5)
D) str.substring(str.length() - 5, 5)
سؤال
Which one of the following is a correct representation of the given mathematical expression in Java? a + b
2

A) a + b % 2
B) / 2
B) a + b / 2
C) a + (b / 2)
D) (a +
سؤال
What is the result of the following statement? String s = "You" + "had" + "me" + "at" + "hello";

A) The string s has the following value: "You had me at "hello"
B) The statement results in an error because the + operator can be used only with numbers
C) The statement results in an error because the + operation cannot be performed on string literals
D) The string s has the following value: "Youhadmeathello"
سؤال
Which of the following is the Java equivalent of the following mathematical expression? c = 2 π\pi . radius

A) c = 2 * Math.PI * radius * 2;
B) c = 2 * Math.PI * Math.pow(2, radius);
C) c = 2 * Math.PI * Math.pow(radius, 2);
D) c = 2 * Math.PI * radius;
سؤال
Which of the methods below are static methods?
I) length
II) substring
III) pow
IV) sqrt

A) All the methods are static
B) Only I, II and III
C) Only II and IV
D) Only III and IV
سؤال
What happens to the fractional part when a division is performed on two integer variables?

A) The fractional part is rounded off to the nearest integer value.
B) The fractional part is discarded.
C) Two integers cannot be used in division; at least one of the operands should be a floating-point number.
D) Instead of using an integer division, you should use the modulus operator to perform floating-point division.
سؤال
Which one of the following statements gives the absolute value of the floating-point number x = -25.50?

A) abs(x);
B) Math.abs(x);
C) x.abs();
D) x.absolute();
سؤال
Which one of the following refers to a number constant that appears in code without explanation?

A) Constant
B) Variable
C) Magic number
D) String literal
سؤال
Which of the following options is valid with reference to the code snippet? public static void main(String[] args)
{
Double d = 45.326;
Double r = d % 9.0;
System.out.println(r);
}

A) The value inside the variable r will be 0.326
B) The value inside the variable r will be 5.036
C) Variable r has to be defined as an integer because the % operator always returns an integer
D) The initialization of variable r is wrong, because the % operator expects integer values as operands
سؤال
What is the output of the following code snippet? public static void main(String[] args)
{
Int s;
Double f = 365.25;
S = f / 10;
System.out.println(s);
}

A) 36
B) 36.525
C) 37
D) No output because the code snippet generates compilation errors
سؤال
What is the output of the following code snippet? public static void main(String[] args){
{
String str1;
Str1 = "I LOVE MY COUNTRY";
String str2 = str1.substring(4, 11);
System.out.println(str2);
}

A) OVE MY
B) OVE MY C
C) VE MY CO
D) VE MY C
سؤال
What output is produced by these statements? String name = "Joanne Hunt";
System.out.println(name.length());

A) 8
B) 10
C) 9
D) 11
سؤال
Consider the following division statements:
I) 22 / 7
II) 22.0 / 7
III) 22 / 7.0
Which of the following is correct?

A) All three statements will return an integer value.
B) Only I will return an integer value.
C) Only I, II will return an integer value.
D) Only I and III will return an integer value.
سؤال
Assuming that the user inputs a value of 25000 for the pay and 10 for the bonus rate in the following code snippet, what is the output? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the pay: ");
Double pay = in.nextDouble();
System.out.print("Enter the bonus rate: ");
Double bonus = in.nextDouble();
System.out.println("The new pay is " +
(pay + pay * (bonus / 100.0)));
}

A) The new pay is 25000
B) The new pay is 25100
C) The new pay is 27500
D) The new pay is 30000
سؤال
What is the output of the following code snippet? public static void main(String[] args)
{
Int var1 = 10;
Int var2 = 2;
Int var3 = 20;
Var3 = var3 / (var1 % var2);
System.out.println(var3);
}

A) 0
B) 4
C) 20
D) There will be no output due to a run-time error.
سؤال
Assuming that the user inputs "Joe" at the prompt, what is the output of the following code snippet? public static void main(String[] args)
{
System.out.print("Enter your name ");
String name;
Scanner in = new Scanner(System.in);
Name = in.next();
Name += ", Good morning";
System.out.print(name);
}

A) The code snippet does not compile because the += operator cannot be used in this context.
B) Joe, Good morning
C) , Good morning
D) Joe
سؤال
Which of the given statements generates the following output? \\\"///

A) System.out.println("\\\"///");
B) System.out.println("\\\\\\\"///");
C) System.out.println("\\\\\\""//////");
D) System.out.println("\\\"///");
سؤال
What is the value of Math.abs(-2)?

A) -2
B) 0
C) 2
D) 4
سؤال
What (if any) type of error occurs with the following code if the user input is ABC? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
String str = in.next();
Int count = Integer.parseInt(str);
System.out.println("Input is " + count);
}

A) Compile-time error
B) Run-time error
C) Overflow error
D) Illegal expression
سؤال
Which one of the following statements defines a constant with the value 123?

A) final int MY_CONST = 123;
B) const int MY_CONST = 123;
C) final int MY_CONST; MY_CONST = 123;
D) static int MY_CONST = 123;
سؤال
Which one of the following statements can be used to get the fifth character from a string str?

A) char c = str.charAt(5);
B) char c = str.charAt(4);
C) char c = str[5];
D) char c = str[4];
سؤال
Which of the given System.out.print statements generates the following output? ABCDE"\

A) System.out.println("ABCDE\"\\");
B) System.out.println("ABCDE"\");
C) System.out.println("ABCDE"\);
D) System.out.println("ABCDE\"\");
سؤال
One way to avoid round-off errors is to use:

A) Math.sqrt()
B) Math.pow()
C) Math.round()
D) Math.truncate()
سؤال
Which one of the following statements can be used to convert a string str to a double?

A) double n = str.parseDouble();
B) double n = Integer.parseDouble(str);
C) double n = Double.parseDouble(str);
D) double n = double.parseDouble(str);
سؤال
What will be the value inside the variables x and y after the given set of assignments?
Int x = 20;
Int y = 10;
X = (x - y) * 2;
Y = x / 2;

A) x = 40, y = 20
B) x = 20, y = 10
C) x = 10, y = 20
D) x = 20, y = 20
سؤال
What is the value inside the var variable at the end of the given code snippet? public static void main(String[] args)
{
Int var = 30;
Var = var + 2 / var;
Var++;
}

A) 0
B) 1
C) 30
D) 31
سؤال
Which one of the following statements can be used to extract the last 10 characters from the string variable str?

A) str.substring(str.length() - 10, str.length())
B) str.substring(10, str.length())
C) str.substring(str.length() - 9, 10)
D) str.substring(0, 10)
سؤال
How do you extract the first 5 characters from the string str?

A) substring(str, 5)
B) substring.str(0, 5)
C) str.substring(5)
D) str.substring(0, 5)
سؤال
Assuming that the user enters 23 and 45 as inputs for num1 and num2, respectively, what is the output of the following code snippet? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
String num1 = in.next();
System.out.print("Enter another number: ");
String num2 = in.next();
System.out.println(num1 + num2);
}

A) 23
B) 4523
C) 68
D) 2345
سؤال
What is the output of the following code snippet? public static void main(String[] args)
{
Double x;
X = Math.pow(3.0, 2.0) + Math.pow(4.0, 2.0);
System.out.println(x);
}

A) 25.0
B) 34
C) 7.0
D) 14
سؤال
Which one of the following statements displays the output as +000321.00?

A) System.out.printf("+%09.2f", 321.0);
B) System.out.printf("%009,2f", 321.0);
C) System.out.printf("+9.2f", 321.0);
D) System.out.printf("%09.00f", 321.0);
سؤال
Which is the Java equivalent of the following mathematical expression? c = (√a + √b)2

A) c = Math.sqrt(a * 2 + b * 2);
B) c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C) c = Math.sqrt(pow(a, 2) + Math.pow(b, 2));
D) c = Math.pow((Math.sqrt(a) + Math.sqrt(b)), 2);
سؤال
Which one of the following statements displays the output as (1.23e+02)?

A) System.out.printf("%(5.2e", -123.0);
B) System.out.printf("%5.2e", -123.0);
C) System.out.printf("^5.2e", -123.0);
D) System.out.printf("%5.2E", -123.0);
سؤال
Which one of the following statements displays the output as 54321.00?

A) System.out.printf("%8.2f", 54321.0);
B) System.out.printf("%8,2f", 54321.0);
C) System.out.printf(",8.2f", 54321.0);
D) System.out.printf("%8.00f", 54321.0);
سؤال
What is the output of the following code snippet? public static void main(String[] args)
{
Int num1 = 10;
Int num2 = 5;
Int num3 = 200;
Num3 = num3 % (num1 * num2);
System.out.println(num3);
}

A) 0
B) 4
C) 10
D) 250
سؤال
Which of the following is the Java equivalent of the following mathematical expression? p = 2 . π\pi . (radius)3

A) p = 2 * Math.PI * (radius * 3);
B) p = Math.PI * Math.pow(3, radius);
C) p = 2 * Math.PI * Math.pow(radius, 3);
D) p = 2 * Math.pow(Math.PI * radius, 3);
سؤال
What does the following statement sequence print? final String str = "Java";
Str += " is powerful";
System.out.println(str);

A) Java is powerful
B) Java + is powerful
C) is powerful
D) Nothing; compile-time error
سؤال
What does the following statement sequence print? String str = "Hello";
Int n = str.length();
String mystery = str.substring(0, 1)
+ str.substring(n - 2, n + 1);
System.out.println(mystery);

A) Run-time error
B) He
C) Ho
D) Hry
سؤال
What does the following statement sequence print? String str = "Java";
Str += " is powerful";
System.out.println(str);

A) Java is powerful
B) Java + is powerful
C) is powerful
D) Compile-time error
سؤال
What is the output of this code snippet? double average;
Int grade1 = 87;
Int grade2 = 94;
// System.out.print("The average is " + (grade1 + grade2) / 2.0);
System.out.print("The average is " + average);

A) Compile-time error
B) The average is 91.5
C) The average is 91.5 The average is 91.5
D) The average is 91.5 The average is 0.0
سؤال
What is the difference between the result of the following two Java statements?
I) int cents = (int)(100 * price + 0.5);
II) int cents = (100 * price + 0.5);

A) Statement I causes truncation, but II does not
B) Statement II causes truncation, but I does not
C) Statement I compiles, but II does not
D) Statement II compiles, but I does not
سؤال
What does the following statement sequence print? String str = "Java Is Good";
Int n = str.length();
String mystery = str.substring(n - 4, n) +
Str)charAt(4) + str.substring(0, 4);
System.out.println(mystery);

A) Java
B) Good Java
C) Good
D) Is Good
سؤال
What is the output of the following code snippet?
Int counter = 0;
Counter++;
System.out.print("The initial value of the counter is ");
System.out.println(count);

A) The initial value of the counter is 0
B) The initial value of the counter is 1
C) The code will not compile
D) The initial value of the counter is
سؤال
What is the output of the following statement sequence? public static void main(String[] args)
{
Int x = 100.0 % 6.0;
System.out.println(x);
}

A) 4
B) Compile-time error
C) Run-time error
D) 16
سؤال
Which statement about number literals in Java is false?

A) Numbers in exponential notation always have type double
B) Zero is an integer
C) Integers must be positive
D) An integer with fractional part of .0 has type double.
سؤال
Which option represents the best choice for a variable name to represent the average grade of students on an exam?

A) averageGrade
B) $averageGrade
C) avg
D) AveGd
سؤال
The typical ranges for integers may seem strange but are derived from

A) Base 10 floating-point precision
B) Field requirements for typical usage and limits
C) Overflows
D) Powers of two because of base 2 representation within the computer
سؤال
What is result of evaluating the following expression? (45 / 6) % 5

A) 2
B) 7
C) 2.5
D) 3
سؤال
Which of the following statements about constants in Java are true?
I) Although not required, constants are commonly named using uppercase letters
II) Only integer values can appear as constants
III) A variable can be defined with an initial value, but the reserved word final prevents it from being changed
IV) A named constant makes computations that use it clearer

A) I, II, III
B) II, III, IV
C) I, III, IV
D) I, II, IV
سؤال
What is the output of this code snippet?
Int sum = 22;
Sum = sum + 2;
System.out.print(sum); // sum = sum + 4;
System.out.print(sum);

A) 2424
B) 2425
C) 2428
D) 2528
سؤال
What does the following statement sequence print if the user input is 123? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number ");
Int myInt = in.nextInt();
MyInt += 456;
System.out.println(myInt);
}

A) 579
B) Compile-time error
C) Run-time error
D) 123456
سؤال
The assignment operator

A) denotes mathematical equality
B) places a new value into a variable
C) means the same as the equals sign used in algebra
D) makes it illegal to write a statement like sum = sum + 4;
سؤال
What does the following statement sequence print? String str = "Harry";
Int n = str.length();
String mystery = str.substring(0, 1) + str.substring(n - 2, n);
System.out.println(mystery);

A) Ha
B) Har
C) Hy
D) Hry
سؤال
Which statements about numeric types in Java are true?
I) There is more than one integer type
II) The data type float uses twice the storage of double
III) The numeric range of the Java integer type is related to powers of two

A) I, II
B) I, III
C) II, III
D) I, II, III
سؤال
What does the following statement sequence print if the user input is 123? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
String str = in.next();
Str += 456;
System.out.println(str);
}

A) 579
B) Compile-time error
C) Run-time error
D) 123456
سؤال
Which statement is true?

A) Variables cannot be assigned and declared in the same statement
B) Variable names must contain at least one dollar sign
C) Variable names can be no more than 8 characters long
D) It is incorrect to initialize a string variable with a number
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/125
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Fundamental Data Types
1
What is the output of the following code snippet? public static void main(String[] args)
{
Double a;
A = Math.sqrt(9.0) + Math.sqrt(16.0);
System.out.println(a);
}

A) 25.0
B) 337.0
C) 7.0
D) 19.0
C
2
What will be the value stored in the variable x after the execution of the following code snippet?
Int a = 10;
Int b = 20;
Int c = 2;
Int x = b / a /*c*/;

A) 1
B) 2
C) 4
D) The code has a syntax error
B
3
Which of the following statements is correct about constants?

A) Constants are written using capital letters because the compiler ignores constants declared in small letters.
B) The data stored inside a constant can be changed using an assignment statement.
C) You can make a variable constant by using the final reserved word when declaring it.
D) Constant variables can only be changed through the Math library.
C
4
What is the result of the following expression? double d = 2.5 + 4 * -1.5 - (2.5 + 4) * -1.5;

A) 24.375
B) 6.25
C) 12.375
D) 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
5
What is the result of the following code snippet? public static void main(String[] args)
{
Double circleRadius;
Double circleVolume = 22 / 7 * circleRadius * circleRadius;
System.out.println(circleVolume);
}

A) 0
B) 3.14
C) 6.28
D) compile-time error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
6
What is wrong with the following code snippet?
Int average;
Average = 78A;

A) The average variable is never initialized.
B) The data type for the average variable is not specified.
C) The average variable is never assigned a value.
D) The average variable is assigned a non-numeric value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which one of the following operators computes the remainder of an integer division?

A) /
B) %
C) \
D) !
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
8
) What are the values of num1 and num2 after this snippet executes? double num1 = 4.20;
Double num2 = num1 * 10 + 5.0;

A) num1 = 4.20 and num2 = 42.0
B) num1 = 4.20 and num2 = 47.0
C) num1 = 42.0 and num2 = 42.0
D) num1 = 42.0 and num2 = 47.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
9
What is wrong with the following code?
Int count = 2000 * 3000 * 4000;

A) Wrong data type
B) Variable is undefined
C) Integer overflow
D) Illegal expression
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which of the following guidelines will make code more explanatory for others?

A) Use more statements in source code.
B) Add comments to source code.
C) Avoid usage of complex calculations in source code.
D) Always enclose the statements in curly braces in source code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
11
Assuming that the user inputs a value of 25 for the price and 10 for the discount rate in the following code snippet, what is the output? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the price: ");
Double price = in.nextDouble();
System.out.print("Enter the discount rate: ");
Double discount = in.nextDouble();
System.out.println("The new price is " +
Price - price * (discount / 100.0));
}

A) The new price is 25
B) The new price is 15
C) The new price is 22.5
D) The new price is 20.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
12
What is the output of the following code snippet? public static void main(String[] args)
{
Int value = 25;
Value = value * 2;
Value--;
System.out.println(value);
}

A) 25
B) 50
C) 49
D) 26
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following statements with comments is(are) valid?
I) int cnt = 0; /* Set count to 0
II) int cnt = 0; /* Set count to 0 */
III) int cnt = 0; // Set count to 0

A) Only I is valid
B) I and II are valid
C) II and III are valid
D) Only III is valid
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
14
What is wrong with the following code snippet? public class Area
{
Public static void main(String[] args)
{
Int width = 10;
Height = 20.00;
System.out.println("area = " + (width * height));
}
}

A) The code snippet uses an uninitialized variable.
B) The code snippet uses an undeclared variable.
C) The code snippet attempts to assign a decimal value to an integer variable.
D) The code snippet attempts to add a number to a string variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
15
What is the value of Math.pow(3, 2)?

A) 6.0
B) 9.0
C) 8.0
D) 5.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
16
What is the output of the following code snippet? public static void main(String[] args)
{
Int value = 3;
Value++;
System.out.println(value);
}

A) 2
B) 3
C) 4
D) No output due to syntax error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following options declares a float variable?

A) Float age;
B) flt age;
C) float age;
D) age: float;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
18
What is the value inside the value variable at the end of the given code snippet? public static void main(String[] args)
{
Int value = 3;
Value = value - 2 * value;
Value++;
}

A) -2
B) 0
C) 2
D) 4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which one of the following variables is assigned with valid literals?

A) int salary = 0;
Salary = 5000.50;
B) int salary1 = 0;
Salary1 = 1.2E6;
C) double salary2 = 0;
Salary2 = 2.96E-2;
D) long salary3 = 0;
Salary3 = 1E-6;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
20
What will be the value inside the variables a and b after the given set of assignments?
Int a = 20;
Int b = 10;
A = (a +

A) a = 15, b = 16
B) / 2; b = a;
A++;
B) a = 16, b = 16
C) a = 16, b = 15
D) a = 15, b = 15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
21
How do you compute the length of the string str?

A) length(str)
B) length.str
C) str.length
D) str.length()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
22
Assuming that the user enters 45 and 62 as inputs for n1 and n2, respectively, what is the output of the following code snippet? public static void main(String[] args)
{
System.out.print("Enter a number: ");
Scanner in = new Scanner(System.in);
String n1 = in.next();
System.out.print("Enter another number: ");
String n2 = in.next();
String result = n1 + n2;
System.out.print(result);
}

A) 46
B) 4662
C) 107
D) 4562
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which is the Java equivalent of the following mathematical expression? c = √(a2 + b2)

A) c = Math.sqrt(a * 2 + b * 2);
B) c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C) c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
D) c = Math.sqrt(Math.pow(a, 2)) + Math.sqrt(Math.pow(b, 2));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which operator is used to concatenate two or more strings?

A) +
B) %
C) &
D) ^
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which one of the following statements can be used to extract the last five characters from any string variable str?

A) str.substring(str.length() - 5, str.length())
B) str.substring(5, 5)
C) str.substring(str.length() - 4, 5)
D) str.substring(str.length() - 5, 5)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
26
Which one of the following is a correct representation of the given mathematical expression in Java? a + b
2

A) a + b % 2
B) / 2
B) a + b / 2
C) a + (b / 2)
D) (a +
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
27
What is the result of the following statement? String s = "You" + "had" + "me" + "at" + "hello";

A) The string s has the following value: "You had me at "hello"
B) The statement results in an error because the + operator can be used only with numbers
C) The statement results in an error because the + operation cannot be performed on string literals
D) The string s has the following value: "Youhadmeathello"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following is the Java equivalent of the following mathematical expression? c = 2 π\pi . radius

A) c = 2 * Math.PI * radius * 2;
B) c = 2 * Math.PI * Math.pow(2, radius);
C) c = 2 * Math.PI * Math.pow(radius, 2);
D) c = 2 * Math.PI * radius;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the methods below are static methods?
I) length
II) substring
III) pow
IV) sqrt

A) All the methods are static
B) Only I, II and III
C) Only II and IV
D) Only III and IV
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
30
What happens to the fractional part when a division is performed on two integer variables?

A) The fractional part is rounded off to the nearest integer value.
B) The fractional part is discarded.
C) Two integers cannot be used in division; at least one of the operands should be a floating-point number.
D) Instead of using an integer division, you should use the modulus operator to perform floating-point division.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which one of the following statements gives the absolute value of the floating-point number x = -25.50?

A) abs(x);
B) Math.abs(x);
C) x.abs();
D) x.absolute();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
32
Which one of the following refers to a number constant that appears in code without explanation?

A) Constant
B) Variable
C) Magic number
D) String literal
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
33
Which of the following options is valid with reference to the code snippet? public static void main(String[] args)
{
Double d = 45.326;
Double r = d % 9.0;
System.out.println(r);
}

A) The value inside the variable r will be 0.326
B) The value inside the variable r will be 5.036
C) Variable r has to be defined as an integer because the % operator always returns an integer
D) The initialization of variable r is wrong, because the % operator expects integer values as operands
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
34
What is the output of the following code snippet? public static void main(String[] args)
{
Int s;
Double f = 365.25;
S = f / 10;
System.out.println(s);
}

A) 36
B) 36.525
C) 37
D) No output because the code snippet generates compilation errors
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
35
What is the output of the following code snippet? public static void main(String[] args){
{
String str1;
Str1 = "I LOVE MY COUNTRY";
String str2 = str1.substring(4, 11);
System.out.println(str2);
}

A) OVE MY
B) OVE MY C
C) VE MY CO
D) VE MY C
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
36
What output is produced by these statements? String name = "Joanne Hunt";
System.out.println(name.length());

A) 8
B) 10
C) 9
D) 11
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
37
Consider the following division statements:
I) 22 / 7
II) 22.0 / 7
III) 22 / 7.0
Which of the following is correct?

A) All three statements will return an integer value.
B) Only I will return an integer value.
C) Only I, II will return an integer value.
D) Only I and III will return an integer value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
38
Assuming that the user inputs a value of 25000 for the pay and 10 for the bonus rate in the following code snippet, what is the output? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the pay: ");
Double pay = in.nextDouble();
System.out.print("Enter the bonus rate: ");
Double bonus = in.nextDouble();
System.out.println("The new pay is " +
(pay + pay * (bonus / 100.0)));
}

A) The new pay is 25000
B) The new pay is 25100
C) The new pay is 27500
D) The new pay is 30000
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
39
What is the output of the following code snippet? public static void main(String[] args)
{
Int var1 = 10;
Int var2 = 2;
Int var3 = 20;
Var3 = var3 / (var1 % var2);
System.out.println(var3);
}

A) 0
B) 4
C) 20
D) There will be no output due to a run-time error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
40
Assuming that the user inputs "Joe" at the prompt, what is the output of the following code snippet? public static void main(String[] args)
{
System.out.print("Enter your name ");
String name;
Scanner in = new Scanner(System.in);
Name = in.next();
Name += ", Good morning";
System.out.print(name);
}

A) The code snippet does not compile because the += operator cannot be used in this context.
B) Joe, Good morning
C) , Good morning
D) Joe
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
41
Which of the given statements generates the following output? \\\"///

A) System.out.println("\\\"///");
B) System.out.println("\\\\\\\"///");
C) System.out.println("\\\\\\""//////");
D) System.out.println("\\\"///");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
42
What is the value of Math.abs(-2)?

A) -2
B) 0
C) 2
D) 4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
43
What (if any) type of error occurs with the following code if the user input is ABC? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
String str = in.next();
Int count = Integer.parseInt(str);
System.out.println("Input is " + count);
}

A) Compile-time error
B) Run-time error
C) Overflow error
D) Illegal expression
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
44
Which one of the following statements defines a constant with the value 123?

A) final int MY_CONST = 123;
B) const int MY_CONST = 123;
C) final int MY_CONST; MY_CONST = 123;
D) static int MY_CONST = 123;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
45
Which one of the following statements can be used to get the fifth character from a string str?

A) char c = str.charAt(5);
B) char c = str.charAt(4);
C) char c = str[5];
D) char c = str[4];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
46
Which of the given System.out.print statements generates the following output? ABCDE"\

A) System.out.println("ABCDE\"\\");
B) System.out.println("ABCDE"\");
C) System.out.println("ABCDE"\);
D) System.out.println("ABCDE\"\");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
47
One way to avoid round-off errors is to use:

A) Math.sqrt()
B) Math.pow()
C) Math.round()
D) Math.truncate()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
48
Which one of the following statements can be used to convert a string str to a double?

A) double n = str.parseDouble();
B) double n = Integer.parseDouble(str);
C) double n = Double.parseDouble(str);
D) double n = double.parseDouble(str);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
49
What will be the value inside the variables x and y after the given set of assignments?
Int x = 20;
Int y = 10;
X = (x - y) * 2;
Y = x / 2;

A) x = 40, y = 20
B) x = 20, y = 10
C) x = 10, y = 20
D) x = 20, y = 20
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
50
What is the value inside the var variable at the end of the given code snippet? public static void main(String[] args)
{
Int var = 30;
Var = var + 2 / var;
Var++;
}

A) 0
B) 1
C) 30
D) 31
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
51
Which one of the following statements can be used to extract the last 10 characters from the string variable str?

A) str.substring(str.length() - 10, str.length())
B) str.substring(10, str.length())
C) str.substring(str.length() - 9, 10)
D) str.substring(0, 10)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
52
How do you extract the first 5 characters from the string str?

A) substring(str, 5)
B) substring.str(0, 5)
C) str.substring(5)
D) str.substring(0, 5)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
53
Assuming that the user enters 23 and 45 as inputs for num1 and num2, respectively, what is the output of the following code snippet? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
String num1 = in.next();
System.out.print("Enter another number: ");
String num2 = in.next();
System.out.println(num1 + num2);
}

A) 23
B) 4523
C) 68
D) 2345
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
54
What is the output of the following code snippet? public static void main(String[] args)
{
Double x;
X = Math.pow(3.0, 2.0) + Math.pow(4.0, 2.0);
System.out.println(x);
}

A) 25.0
B) 34
C) 7.0
D) 14
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
55
Which one of the following statements displays the output as +000321.00?

A) System.out.printf("+%09.2f", 321.0);
B) System.out.printf("%009,2f", 321.0);
C) System.out.printf("+9.2f", 321.0);
D) System.out.printf("%09.00f", 321.0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
56
Which is the Java equivalent of the following mathematical expression? c = (√a + √b)2

A) c = Math.sqrt(a * 2 + b * 2);
B) c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C) c = Math.sqrt(pow(a, 2) + Math.pow(b, 2));
D) c = Math.pow((Math.sqrt(a) + Math.sqrt(b)), 2);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
57
Which one of the following statements displays the output as (1.23e+02)?

A) System.out.printf("%(5.2e", -123.0);
B) System.out.printf("%5.2e", -123.0);
C) System.out.printf("^5.2e", -123.0);
D) System.out.printf("%5.2E", -123.0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
58
Which one of the following statements displays the output as 54321.00?

A) System.out.printf("%8.2f", 54321.0);
B) System.out.printf("%8,2f", 54321.0);
C) System.out.printf(",8.2f", 54321.0);
D) System.out.printf("%8.00f", 54321.0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
59
What is the output of the following code snippet? public static void main(String[] args)
{
Int num1 = 10;
Int num2 = 5;
Int num3 = 200;
Num3 = num3 % (num1 * num2);
System.out.println(num3);
}

A) 0
B) 4
C) 10
D) 250
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
60
Which of the following is the Java equivalent of the following mathematical expression? p = 2 . π\pi . (radius)3

A) p = 2 * Math.PI * (radius * 3);
B) p = Math.PI * Math.pow(3, radius);
C) p = 2 * Math.PI * Math.pow(radius, 3);
D) p = 2 * Math.pow(Math.PI * radius, 3);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
61
What does the following statement sequence print? final String str = "Java";
Str += " is powerful";
System.out.println(str);

A) Java is powerful
B) Java + is powerful
C) is powerful
D) Nothing; compile-time error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
62
What does the following statement sequence print? String str = "Hello";
Int n = str.length();
String mystery = str.substring(0, 1)
+ str.substring(n - 2, n + 1);
System.out.println(mystery);

A) Run-time error
B) He
C) Ho
D) Hry
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
63
What does the following statement sequence print? String str = "Java";
Str += " is powerful";
System.out.println(str);

A) Java is powerful
B) Java + is powerful
C) is powerful
D) Compile-time error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
64
What is the output of this code snippet? double average;
Int grade1 = 87;
Int grade2 = 94;
// System.out.print("The average is " + (grade1 + grade2) / 2.0);
System.out.print("The average is " + average);

A) Compile-time error
B) The average is 91.5
C) The average is 91.5 The average is 91.5
D) The average is 91.5 The average is 0.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
65
What is the difference between the result of the following two Java statements?
I) int cents = (int)(100 * price + 0.5);
II) int cents = (100 * price + 0.5);

A) Statement I causes truncation, but II does not
B) Statement II causes truncation, but I does not
C) Statement I compiles, but II does not
D) Statement II compiles, but I does not
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
66
What does the following statement sequence print? String str = "Java Is Good";
Int n = str.length();
String mystery = str.substring(n - 4, n) +
Str)charAt(4) + str.substring(0, 4);
System.out.println(mystery);

A) Java
B) Good Java
C) Good
D) Is Good
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
67
What is the output of the following code snippet?
Int counter = 0;
Counter++;
System.out.print("The initial value of the counter is ");
System.out.println(count);

A) The initial value of the counter is 0
B) The initial value of the counter is 1
C) The code will not compile
D) The initial value of the counter is
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
68
What is the output of the following statement sequence? public static void main(String[] args)
{
Int x = 100.0 % 6.0;
System.out.println(x);
}

A) 4
B) Compile-time error
C) Run-time error
D) 16
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
69
Which statement about number literals in Java is false?

A) Numbers in exponential notation always have type double
B) Zero is an integer
C) Integers must be positive
D) An integer with fractional part of .0 has type double.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
70
Which option represents the best choice for a variable name to represent the average grade of students on an exam?

A) averageGrade
B) $averageGrade
C) avg
D) AveGd
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
71
The typical ranges for integers may seem strange but are derived from

A) Base 10 floating-point precision
B) Field requirements for typical usage and limits
C) Overflows
D) Powers of two because of base 2 representation within the computer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
72
What is result of evaluating the following expression? (45 / 6) % 5

A) 2
B) 7
C) 2.5
D) 3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
73
Which of the following statements about constants in Java are true?
I) Although not required, constants are commonly named using uppercase letters
II) Only integer values can appear as constants
III) A variable can be defined with an initial value, but the reserved word final prevents it from being changed
IV) A named constant makes computations that use it clearer

A) I, II, III
B) II, III, IV
C) I, III, IV
D) I, II, IV
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
74
What is the output of this code snippet?
Int sum = 22;
Sum = sum + 2;
System.out.print(sum); // sum = sum + 4;
System.out.print(sum);

A) 2424
B) 2425
C) 2428
D) 2528
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
75
What does the following statement sequence print if the user input is 123? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number ");
Int myInt = in.nextInt();
MyInt += 456;
System.out.println(myInt);
}

A) 579
B) Compile-time error
C) Run-time error
D) 123456
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
76
The assignment operator

A) denotes mathematical equality
B) places a new value into a variable
C) means the same as the equals sign used in algebra
D) makes it illegal to write a statement like sum = sum + 4;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
77
What does the following statement sequence print? String str = "Harry";
Int n = str.length();
String mystery = str.substring(0, 1) + str.substring(n - 2, n);
System.out.println(mystery);

A) Ha
B) Har
C) Hy
D) Hry
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
78
Which statements about numeric types in Java are true?
I) There is more than one integer type
II) The data type float uses twice the storage of double
III) The numeric range of the Java integer type is related to powers of two

A) I, II
B) I, III
C) II, III
D) I, II, III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
79
What does the following statement sequence print if the user input is 123? public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
String str = in.next();
Str += 456;
System.out.println(str);
}

A) 579
B) Compile-time error
C) Run-time error
D) 123456
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
80
Which statement is true?

A) Variables cannot be assigned and declared in the same statement
B) Variable names must contain at least one dollar sign
C) Variable names can be no more than 8 characters long
D) It is incorrect to initialize a string variable with a number
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 125 في هذه المجموعة.