Deck 3: Introduction to Objects and Input/output
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
العب
ملء الشاشة (f)
Deck 3: Introduction to Objects and Input/output
1
In a string, the index (position) of the first character is 1.
False
2
In order to use a predefined method, you only need to know the name of the method and the type of each parameter.
False
3
To use the contents of the java.lang package in a program, they must be imported using the import statement.
False
4
Suppose z = 1834.762. The output of the statementSystem.out.printf("%.1f", z);is 1834.800.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
The dot (.) operator is also called the member specific operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
The method printf is used only to format the output of integers and decimal numbers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
The new operator is used to create an int variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
The value of the expression Integer.parseInt("+782") is "782".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
Java provides automatic garbage collection.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
Given int num; the value of num is directly stored in its memory space.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
If length denotes the length of a nonnull string, then length - 1 gives the index of the last character in the string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
The default output of decimal numbers of the type float is up to nine decimal places.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
Reference type variables directly store data into their memory space.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
String objects are mutable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
In a format specifier, if the flag is set to 'l', then the output of the result is left justified.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
The classes Integer, Float, and Double are called wrapper classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
Suppose that name is a String variable. Then the following two statements are equivalent.name = "Danny";
name = new String("Danny");
name = new String("Danny");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
In the class String, the substring method inserts a string into another string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
In a format specifier, the option width specifies the maximum number of characters to be written to the output.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
String variables are reference variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following method is contained in the package java.util?
A) format
B) Integer
C) nextInt
D) printf
A) format
B) Integer
C) nextInt
D) printf
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 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.
B) The computer will crash.
C) A syntax error will be reported.
D) The program will execute as planned.
A) An exception will be thrown.
B) The computer will crash.
C) A syntax error will be reported.
D) The program will execute as planned.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
What is the value of the following statement?
Math.pow(3,4)
A) 7
B) 12
C) 34
D) 81
Math.pow(3,4)
A) 7
B) 12
C) 34
D) 81
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
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
B) "Sunny day"
C) 3600 + "Sunny day"
D) None of these
A) the memory address 3600
B) "Sunny day"
C) 3600 + "Sunny day"
D) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
In Java, all variables declared using a class are ____.
A) primitive variables
B) reference variables
C) constants
D) operators
A) primitive variables
B) reference variables
C) constants
D) operators
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 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
B) object call
C) class
D) method call
A) system call
B) object call
C) class
D) method call
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which package is automatically imported by the Java system?
A) java.io
B) java.lang
C) java.util
D) java.swing
A) java.io
B) java.lang
C) java.util
D) java.swing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
There are ____ type(s) of methods in a class.
A) one
B) two
C) three
D) four
A) one
B) two
C) three
D) four
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which of the following is the member access operator?
A) +
B) .
C) -
D) ->
A) +
B) .
C) -
D) ->
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
The statement System.exit(0); is found at the end of every working Java program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
Which statement instructs a program to run the garbage collector?
A) System.clearGarbage();
B) System.flushGarbage();
C) System.out();
D) System.gc();
A) System.clearGarbage();
B) System.flushGarbage();
C) System.out();
D) System.gc();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
String sentence;
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of length1?
A) 20
B) 21
C) 24
D) 26
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of length1?
A) 20
B) 21
C) 24
D) 26
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
String sentence;
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of str1?
A) exam i
B) exam
C) exam is
D) on Monday
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of str1?
A) exam i
B) exam
C) exam is
D) on Monday
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
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
36
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
37
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)
B) Only (i) and (ii)
C) Only (iii)
D) Only (ii) and (iii)
(i) int num = new int(67);
(ii) String name = new ("Doe");
(iii) String name = "Doe";
A) Only (i)
B) Only (i) and (ii)
C) Only (iii)
D) Only (ii) and (iii)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
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";
A) new String = "Programming";
B) String new = "Programming";
C) str = "Programming";
D) str new "Programming";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
The class JOptionPane is part of the package java.swing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
String sentence;
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of str2?
A) Firs
B) First
C) Monda
D) exam
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of str2?
A) Firs
B) First
C) Monda
D) exam
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
What is the output of the following statement?System.out.printf("%.2f", 48.9);
A) 48.00
B) 48.90
C) 49
D) 49.00
A) 48.00
B) 48.90
C) 49
D) 49.00
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
Which of the following is an area of secondary storage used to hold information?
A) file
B) variable
C) constant
D) buffer
A) file
B) variable
C) constant
D) buffer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
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);
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
44
The showMessageDialog method has ____ parameter(s).
A) one
B) two
C) three
D) four
A) one
B) two
C) three
D) four
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
String sentence;
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();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###########."
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();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
46
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"
B) "285.680"
C) "285.68"
D) "285.068"
String y;y = String.format("%.2f", x);If x = 285.679, what is the value of y?
A) "285.00"
B) "285.680"
C) "285.68"
D) "285.068"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
String sentence;
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of str4?
A) 11
B) 12
C) 13
D) 14
String str1, str2, str3, str4;
Int length1;sentence = "First exam is on Monday.";str1 = sentence.substring(6, 12);
Str2 = str1.substring(0, 4);
Str3 = sentence.replace('i', '#');
Str4 = sentence.indexOf("on");length1 = sentence.length();Based on the code above, what is the value of str4?
A) 11
B) 12
C) 13
D) 14
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
Which of the following statements would store input in name?
A) name = JOptionPane.showInputDialog("Enter your name and press OK");
B) name = JOptionPane.showMessageDialog("Enter your name and press OK",
JOptionPane.PLAIN_MESSAGE, null);
C) name = System.in();
D) name = JOptionPane.input("Enter your name and press OK");
A) name = JOptionPane.showInputDialog("Enter your name and press OK");
B) name = JOptionPane.showMessageDialog("Enter your name and press OK",
JOptionPane.PLAIN_MESSAGE, null);
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.
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
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
94 73.92 Programming
B) 123456789012345678901234567890
94 73.92 Programming
C) 123456789012345678901234567890 94 73.92 Programming
D) 123456789012345678901234567890
94 73.92 Programming
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
94 73.92 Programming
B) 123456789012345678901234567890
94 73.92 Programming
C) 123456789012345678901234567890 94 73.92 Programming
D) 123456789012345678901234567890
94 73.92 Programming
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck