Deck 3: Introduction to Objects and Inputoutput

ملء الشاشة (f)
exit full mode
سؤال
The default output of decimal numbers of the type float is up to nine decimal places.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
String variables are reference variables.
سؤال
If length denotes the length of a nonnull string, then length - 1 gives the index of the last character in the string.
سؤال
String objects are mutable.
سؤال
Suppose z = 1834.762. The output of the statement System.out.printf("%.1f", z); is 1834.800.
سؤال
In the class String, the substring method inserts a string into another string.
سؤال
The method printf is used only to format the output of integers and decimal numbers.
سؤال
Reference type variables directly store data into their memory space.
سؤال
Given int num; the value of num is directly stored in its memory space.
سؤال
The new operator is used to create an int variable.
سؤال
In a format specifier, the option width specifies the maximum number of characters to be written to the output.
سؤال
The classes Integer, Float, and Double are called wrapper classes.
سؤال
In a string, the index (position) of the first character is 1.
سؤال
Suppose that name is a String variable. Then the following two statements are equivalent. name = "Danny"; name = new String("Danny");
سؤال
To use the contents of the java.lang package in a program, they must be imported using the import statement.
سؤال
Java provides automatic garbage collection.
سؤال
In a format specifier, if the flag is set to 'l', then the output of the result is left justified.
سؤال
In order to use a predefined method, you only need to know the name of the method and the type of each parameter.
سؤال
The value of the expression Integer.parseInt("+782") is "782".
سؤال
The dot (.) operator is also called the member specific operator.
سؤال
When writing output to a file, if the file is not closed at the end of the program, you may not be able to view your output properly.
سؤال
What will most probably happen if you omit the dot operator when accessing a method?

A) An exception will be thrown.
C) A syntax error will be reported.
B) The computer will crash.
D) The program will execute as planned.
سؤال
Which of the following is the member access operator?

A) +
C) -
B) .
D) ->
سؤال
In Java, all variables declared using a class are ____.

A) primitive variables
C) constants
B) reference variables
D) operators
سؤال
Given a decimal number, the method format of the class String returns the string containing the digits of the formatted number.
سؤال
The class JOptionPane allows a programmer to use graphical interface components to obtain input from a user.
سؤال
An expression such as str.length(); is an example of a(n) ____.

A) system call
C) class
B) object call
D) method call
سؤال
What is the value of the following statement? Math.pow(3,4)

A) 7
C) 34
B) 12
D) 81
سؤال
Suppose str is a String variable. The statement str = new String("Programming"); is similar to which of the following?

A) new String = "Programming";
B) String new = "Programming";
C) str = "Programming";
D) str new "Programming";
سؤال
Which package is automatically imported by the Java system?

A) java.io
C) java.util
B) java.lang
D) java.swing
سؤال
There are ____ type(s) of methods in a class.

A) one
C) three
B) two
D) four
سؤال
The statement System.exit(0); is found at the end of every working Java program.
سؤال
Which statement instructs a program to run the garbage collector?

A) System.clearGarbage();
B) System.flushGarbage();
C) System.out();
D) System.gc();
سؤال
Which of the following method is contained in the package java.util?

A) format
C) nextInt
B) Integer
D) printf
سؤال
Based on the code above, what is the value of str1?

A) exam i
C) exam is
B) exam
D) on Monday
سؤال
The class JOptionPane is part of the package java.swing.
سؤال
Suppose the String variable str points to the String object "Sunny day" at the memory address 3600. Then the value of str is:

A) the memory address 3600
C) 3600 + "Sunny day"
B) "Sunny day"
D) None of these
سؤال
Based on the code above, what is the value of str2?

A) Firs
C) Monda
B) First
D) exam
سؤال
Based on the code above, what is the value of length1?

A) 20
C) 24
B) 21
D) 26
سؤال
Which of the following is a valid statement? (i) int num = new int(67); (ii) String name = new ("Doe"); (iii) String name = "Doe";

A) Only (i)
C) Only (iii)
B) Only (i) and (ii)
D) Only (ii) and (iii)
سؤال
Suppose that you have the declaration: int num = 94; double x = 73.92; String str = "Programming"; What is the output of the following statements? System.out.println("123456789012345678901234567890"); System.out.printf("%5d%6.2f %15s%n", num, x, str);

A) 123456789012345678901234567890
B) 123456789012345678901234567890
C) 123456789012345678901234567890
D) 123456789012345678901234567890
سؤال
Based on the code above, what is the value of str3?

A) "First exam is on Monday."
B) "F#rst exam #s on Monday."
C) "F#rst exam is on Monday."
D) "#i### #### i###########."
سؤال
Consider the following statements. double x; String y; y = String.format("%.2f", x); If x = 285.679, what is the value of y?

A) "285.00"
C) "285.68"
B) "285.680"
D) "285.068"
سؤال
Which of the following outputs 56734.9875 to three decimal places?

A) System.out.printf("3f%", 56734.9875);
B) System.out.printf(".3f%", 56734.9875);
C) System.out.printf(".03f%", 56734.9875);
D) System.out.printf("%.3f", 56734.9875);
سؤال
The showMessageDialog method has ____ parameter(s).

A) one
C) three
B) two
D) four
سؤال
What is the output of the following statement? System.out.printf("%.2f", 48.9);

A) 48.00
C) 49
B) 48.90
D) 49.00
سؤال
Which of the following is an area of secondary storage used to hold information?

A) file
C) constant
B) variable
D) buffer
سؤال
Which of the following statements would store input in name?

A) name =
B) name =
C) name = System.in();
D) name = JOptionPane.input("Enter your name and press OK");
سؤال
What happens when JOptionPane.PLAIN_MESSAGE is chosen as the messageType parameter?

A) No icon is displayed in the dialog box.
B) An X is displayed in the dialog box.
C) A question mark is displayed in the dialog box.
D) An exclamation point is displayed in the dialog box.
سؤال
Based on the code above, what is the value of str4?

A) 11
C) 13
B) 12
D) 14
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Introduction to Objects and Inputoutput
1
The default output of decimal numbers of the type float is up to nine decimal places.
False
2
String variables are reference variables.
True
3
If length denotes the length of a nonnull string, then length - 1 gives the index of the last character in the string.
True
4
String objects are mutable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
Suppose z = 1834.762. The output of the statement System.out.printf("%.1f", z); is 1834.800.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
In the class String, the substring method inserts a string into another string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
The method printf is used only to format the output of integers and decimal numbers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
Reference type variables directly store data into their memory space.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
Given int num; the value of num is directly stored in its memory space.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
The new operator is used to create an int variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
In a format specifier, the option width specifies the maximum number of characters to be written to the output.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
The classes Integer, Float, and Double are called wrapper classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
In a string, the index (position) of the first character is 1.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
Suppose that name is a String variable. Then the following two statements are equivalent. name = "Danny"; name = new String("Danny");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
To use the contents of the java.lang package in a program, they must be imported using the import statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
Java provides automatic garbage collection.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
In a format specifier, if the flag is set to 'l', then the output of the result is left justified.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
In order to use a predefined method, you only need to know the name of the method and the type of each parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
The value of the expression Integer.parseInt("+782") is "782".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
The dot (.) operator is also called the member specific operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
When writing output to a file, if the file is not closed at the end of the program, you may not be able to view your output properly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
What will most probably happen if you omit the dot operator when accessing a method?

A) An exception will be thrown.
C) A syntax error will be reported.
B) The computer will crash.
D) The program will execute as planned.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which of the following is the member access operator?

A) +
C) -
B) .
D) ->
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
In Java, all variables declared using a class are ____.

A) primitive variables
C) constants
B) reference variables
D) operators
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
Given a decimal number, the method format of the class String returns the string containing the digits of the formatted number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
The class JOptionPane allows a programmer to use graphical interface components to obtain input from a user.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
An expression such as str.length(); is an example of a(n) ____.

A) system call
C) class
B) object call
D) method call
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
What is the value of the following statement? Math.pow(3,4)

A) 7
C) 34
B) 12
D) 81
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
Suppose str is a String variable. The statement str = new String("Programming"); is similar to which of the following?

A) new String = "Programming";
B) String new = "Programming";
C) str = "Programming";
D) str new "Programming";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which package is automatically imported by the Java system?

A) java.io
C) java.util
B) java.lang
D) java.swing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
There are ____ type(s) of methods in a class.

A) one
C) three
B) two
D) four
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
The statement System.exit(0); is found at the end of every working Java program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
Which statement instructs a program to run the garbage collector?

A) System.clearGarbage();
B) System.flushGarbage();
C) System.out();
D) System.gc();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
Which of the following method is contained in the package java.util?

A) format
C) nextInt
B) Integer
D) printf
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
Based on the code above, what is the value of str1?

A) exam i
C) exam is
B) exam
D) on Monday
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
The class JOptionPane is part of the package java.swing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
Suppose the String variable str points to the String object "Sunny day" at the memory address 3600. Then the value of str is:

A) the memory address 3600
C) 3600 + "Sunny day"
B) "Sunny day"
D) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
Based on the code above, what is the value of str2?

A) Firs
C) Monda
B) First
D) exam
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
Based on the code above, what is the value of length1?

A) 20
C) 24
B) 21
D) 26
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
Which of the following is a valid statement? (i) int num = new int(67); (ii) String name = new ("Doe"); (iii) String name = "Doe";

A) Only (i)
C) Only (iii)
B) Only (i) and (ii)
D) Only (ii) and (iii)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
Suppose that you have the declaration: int num = 94; double x = 73.92; String str = "Programming"; What is the output of the following statements? System.out.println("123456789012345678901234567890"); System.out.printf("%5d%6.2f %15s%n", num, x, str);

A) 123456789012345678901234567890
B) 123456789012345678901234567890
C) 123456789012345678901234567890
D) 123456789012345678901234567890
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
Based on the code above, what is the value of str3?

A) "First exam is on Monday."
B) "F#rst exam #s on Monday."
C) "F#rst exam is on Monday."
D) "#i### #### i###########."
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
Consider the following statements. double x; String y; y = String.format("%.2f", x); If x = 285.679, what is the value of y?

A) "285.00"
C) "285.68"
B) "285.680"
D) "285.068"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
Which of the following outputs 56734.9875 to three decimal places?

A) System.out.printf("3f%", 56734.9875);
B) System.out.printf(".3f%", 56734.9875);
C) System.out.printf(".03f%", 56734.9875);
D) System.out.printf("%.3f", 56734.9875);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
The showMessageDialog method has ____ parameter(s).

A) one
C) three
B) two
D) four
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
What is the output of the following statement? System.out.printf("%.2f", 48.9);

A) 48.00
C) 49
B) 48.90
D) 49.00
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
Which of the following is an area of secondary storage used to hold information?

A) file
C) constant
B) variable
D) buffer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
Which of the following statements would store input in name?

A) name =
B) name =
C) name = System.in();
D) name = JOptionPane.input("Enter your name and press OK");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
What happens when JOptionPane.PLAIN_MESSAGE is chosen as the messageType parameter?

A) No icon is displayed in the dialog box.
B) An X is displayed in the dialog box.
C) A question mark is displayed in the dialog box.
D) An exclamation point is displayed in the dialog box.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
Based on the code above, what is the value of str4?

A) 11
C) 13
B) 12
D) 14
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.