Deck 3: Introduction to Classes, Objects, Methods and Strings

ملء الشاشة (f)
exit full mode
سؤال
Java requires a ________ call for every object that's created.

A) constructor
B) destructor
C) parameterless
D) parameterized
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which of the following statements is false?

A) Each class declaration that begins with the access modifier private must be stored in a file that has the same name as the class and ends with the .java filename extension.
B) Every class declaration contains keyword class followed immediately by the class's name.
C) Class, method and variable names are identifiers.
D) An object has attributes that are implemented as instance variables and carried with it throughout its lifetime.
سؤال
Which of the following statements is false?

A) The javac command can compile multiple classes at once; simply list the source-code filenames after the command with each filename separated by a comma from the next.
B) If the directory containing the app includes only one app's files, you can compile all of its classes with the command javac *.java.
C) The asterisk (*) in javac *.java indicates that all files in the current directory ending with the filename extension ".java" should be compiled.
D) All of the above are true.
سؤال
Which of the following statements is false?

A) Scanner method next reads characters until any white-space character is encountered, then returns the characters as a String.
B) To call a method of an object, follow the object name with a comma, the method name and a set of parentheses containing the method's arguments.
C) A class instance creation expression begins with keyword new and creates a new object.
D) A constructor is similar to a method but is called implicitly by the new operator to initialize an object's instance variables at the time the object is created.
سؤال
Declaring instance variables ________ is known as data hiding or information hiding.

A) secure
B) private
C) static
D) masked
سؤال
A class that creates an object of another class, then calls the object's methods, is called a(n) ________ class.

A) object-oriented
B) inherited
C) caller
D) driver.
سؤال
Which of the following statements is false?

A) Variables declared in the body of a particular method are local variables and can be used only in that method.
B) A method's parameters are local variables of the method.
C) Every method's body is delimited by left and right braces ({ and }).
D) Keyword null indicates that a method will perform a task but will not return any information.
سؤال
A key part of enabling the JVM to locate and call method main to begin the app's execution is the ________ keyword, which indicates that main can be called without first creating an object of the class in which the method is declared.

A) stable
B) private
C) static
D) public
سؤال
Which of the following statements is false?

A) The method's return type specifies the type of data returned to a method's caller.
B) Empty parentheses following a method name indicate that the method does not require any parameters to perform its task.
C) When a method that specifies a return type other than void is called and completes its task, the method must return a result to its calling method
D) Classes often provide public methods to allow the class's clients to set or get private instance variables; the names of these methods must begin with set or get.
سؤال
Which of the following statements is false?

A) Most classes you'll use in Java programs must be imported explicitly.
B) There's a special relationship between classes that are compiled in the same directory. By default, such classes are considered to be in the same package-known as the default package.
C) Classes in the same package are implicitly imported into main.
D) An import declaration is not required when one class in a package uses another in the same package.
سؤال
An import declaration is not required if you always refer to a class with its ________ name, which includes its package name and class name.

A) compile-time
B) default package
C) paired
D) fully qualified name
سؤال
Each class you create becomes a new ________ that can be used to declare variables and create objects.

A) package
B) instance
C) library
D) type.
سؤال
You must call most methods other than ________ explicitly to tell them to perform their tasks.

A) public methods
B) main
C) static methods
D) private methods
سؤال
When a method terminates, the values of its local variables are ________.

A) saved
B) copied
C) restored
D) lost
سؤال
Which of the following statements is true?

A) Local variables are automatically initialized.
B) Every instance variable has a default initial value-a value provided by Java when you do not specify the instance variable's initial value.
C) The default value for an instance variable of type String is void.
D) The argument types in the method call must be identical to the types of the corresponding parameters in the method's declaration.
E)
سؤال
Which of the following statements is false?

A) In the UML, each class is modeled in a class diagram as a rectangle with three compartments. The top one contains the class's name centered horizontally in boldface. The middle one contains the class's attributes, which correspond to instance variables in Java. The bottom one contains the class's operations, which correspond to methods and constructors in Java.
B) UML represents instance variables as an attribute name, followed by a colon and the type.
C) Private attributes are preceded by the keyword private in the UML.
D) The UML models operations by listing the operation name followed by a set of parentheses. A plus sign (+) in front of the operation name indicates that the operation is a public.
سؤال
Which of the following statements is true?

A) The UML models a parameter of an operation by listing the parameter name, followed by a colon and the parameter value between the parentheses after the operation name.
B) The UML indicates an operation's return type by placing a colon and the return value after the parentheses following the operation name.
C) UML class diagrams do not specify return types for operations that do not return values.
D) Declaring instance variables public is known as data hiding or information hiding.
سؤال
Which of the following statements is true?

A) Each object (instance) of the class shares the class's instance variables.
B) Most instance-variable declarations are preceded with the keyword public, which is an access modifier.
C) Variables or methods declared with access modifier private are accessible only to methods of the class in which they're declared.
D) None of the above is true.
سؤال
Which of the following statements is false?

A) By convention class names begin with an uppercase letter, and method and variable names begin with a lowercase letter.
B) Instance variables exist before methods are called on an object, while the methods are executing and after the methods complete execution.
C) A class normally contains one or more methods that manipulate the instance variables that belong to particular objects of the class.
D) Instance variables can be declared anywhere inside a class.
سؤال
You can declare new classes as needed; this is one reason Java is known as a(n) ________ language.

A) portable
B) incremental
C) extensible
D) virtual
سؤال
Which of the following statements is true?

A) Constructors can specify parameters and return types.
B) Constructors can specify parameters but not return types.
C) Constructors cannot specify parameters but can specify return types.
D) Constructors can specify neither parameters nor return types.
سؤال
Which of the following statements is false?

A) A floating-point number is a number with a decimal point.
B) Java provides two primitive types for storing floating-point numbers in memory-float and double.
C) Variables of type float represent single-precision floating-point numbers and have seven significant digits.
D) Variables of type double represent double-precision floating-point numbers; these require twice as much memory as float variables and provide 14 significant digits.
سؤال
A __________ of a class called MyClass is another class whose methods call the methods of MyClass.

A) consumer
B) servant
C) caller
D) client
سؤال
The format specifier %.2f specifies that two digits of precision should be output ________ in the floating-point number.

A) to the left of the decimal point
B) centered
C) to the right of the decimal point
D) None of the above.
سؤال
The format specifier ________ is used to output values of type float or double.

A) %f
B) %d
C) %fd
D) %r
سؤال
Which of the following statements is false?

A) A primitive-type variable can store exactly one value of its declared type at a time.
B) Primitive-type instance variables are initialized by default.
C) Variables of types byte, char, short, int, long, float and double are initialized to 0.
D) Variables of type boolean are initialized to true.
سؤال
Which of the following statements is false?

A) If a class does not define constructors, the compiler provides a default constructor with no parameters.
B) If you declare a constructor for a class, the compiler will not create a default constructor for that class.
C) The UML models constructors in the third compartment of a class diagram.
D) To distinguish a constructor from a class's operations, the UML places the word "constructor" between double quotes before the constructor's name.
سؤال
Floating-point literals are of type ________ by default.

A) float
B) double
C) real
D) decimal
سؤال
Reference-type variables (called references) store ________ in memory.

A) the value of an object
B) a copy of an object
C) the location of an object
D) the size of an object
سؤال
Which of the following statements is false?

A) A reference to an object is required to invoke an object's methods.
B) A primitive-type variable does not refer to an object.
C) Reference-type instance variables are initialized by default to the value void.
D) A primitive-type variable cannot be used to invoke a method.
سؤال
If a class does not define constructors, the compiler provides a default constructor with no parameters, and the class's instance variables are initialized to ________.

A) zero
B) null
C) their default values.
D) false
سؤال
Types in Java are divided into two categories. The primitive types are boolean, byte, char, short, int, long, float and double. All other types are ________ types.

A) static
B) reference
C) declared
D) source
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/32
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Introduction to Classes, Objects, Methods and Strings
1
Java requires a ________ call for every object that's created.

A) constructor
B) destructor
C) parameterless
D) parameterized
constructor
2
Which of the following statements is false?

A) Each class declaration that begins with the access modifier private must be stored in a file that has the same name as the class and ends with the .java filename extension.
B) Every class declaration contains keyword class followed immediately by the class's name.
C) Class, method and variable names are identifiers.
D) An object has attributes that are implemented as instance variables and carried with it throughout its lifetime.
A
3
Which of the following statements is false?

A) The javac command can compile multiple classes at once; simply list the source-code filenames after the command with each filename separated by a comma from the next.
B) If the directory containing the app includes only one app's files, you can compile all of its classes with the command javac *.java.
C) The asterisk (*) in javac *.java indicates that all files in the current directory ending with the filename extension ".java" should be compiled.
D) All of the above are true.
A
4
Which of the following statements is false?

A) Scanner method next reads characters until any white-space character is encountered, then returns the characters as a String.
B) To call a method of an object, follow the object name with a comma, the method name and a set of parentheses containing the method's arguments.
C) A class instance creation expression begins with keyword new and creates a new object.
D) A constructor is similar to a method but is called implicitly by the new operator to initialize an object's instance variables at the time the object is created.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
5
Declaring instance variables ________ is known as data hiding or information hiding.

A) secure
B) private
C) static
D) masked
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
6
A class that creates an object of another class, then calls the object's methods, is called a(n) ________ class.

A) object-oriented
B) inherited
C) caller
D) driver.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following statements is false?

A) Variables declared in the body of a particular method are local variables and can be used only in that method.
B) A method's parameters are local variables of the method.
C) Every method's body is delimited by left and right braces ({ and }).
D) Keyword null indicates that a method will perform a task but will not return any information.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
8
A key part of enabling the JVM to locate and call method main to begin the app's execution is the ________ keyword, which indicates that main can be called without first creating an object of the class in which the method is declared.

A) stable
B) private
C) static
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following statements is false?

A) The method's return type specifies the type of data returned to a method's caller.
B) Empty parentheses following a method name indicate that the method does not require any parameters to perform its task.
C) When a method that specifies a return type other than void is called and completes its task, the method must return a result to its calling method
D) Classes often provide public methods to allow the class's clients to set or get private instance variables; the names of these methods must begin with set or get.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which of the following statements is false?

A) Most classes you'll use in Java programs must be imported explicitly.
B) There's a special relationship between classes that are compiled in the same directory. By default, such classes are considered to be in the same package-known as the default package.
C) Classes in the same package are implicitly imported into main.
D) An import declaration is not required when one class in a package uses another in the same package.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
11
An import declaration is not required if you always refer to a class with its ________ name, which includes its package name and class name.

A) compile-time
B) default package
C) paired
D) fully qualified name
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
12
Each class you create becomes a new ________ that can be used to declare variables and create objects.

A) package
B) instance
C) library
D) type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
13
You must call most methods other than ________ explicitly to tell them to perform their tasks.

A) public methods
B) main
C) static methods
D) private methods
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
14
When a method terminates, the values of its local variables are ________.

A) saved
B) copied
C) restored
D) lost
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following statements is true?

A) Local variables are automatically initialized.
B) Every instance variable has a default initial value-a value provided by Java when you do not specify the instance variable's initial value.
C) The default value for an instance variable of type String is void.
D) The argument types in the method call must be identical to the types of the corresponding parameters in the method's declaration.
E)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which of the following statements is false?

A) In the UML, each class is modeled in a class diagram as a rectangle with three compartments. The top one contains the class's name centered horizontally in boldface. The middle one contains the class's attributes, which correspond to instance variables in Java. The bottom one contains the class's operations, which correspond to methods and constructors in Java.
B) UML represents instance variables as an attribute name, followed by a colon and the type.
C) Private attributes are preceded by the keyword private in the UML.
D) The UML models operations by listing the operation name followed by a set of parentheses. A plus sign (+) in front of the operation name indicates that the operation is a public.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following statements is true?

A) The UML models a parameter of an operation by listing the parameter name, followed by a colon and the parameter value between the parentheses after the operation name.
B) The UML indicates an operation's return type by placing a colon and the return value after the parentheses following the operation name.
C) UML class diagrams do not specify return types for operations that do not return values.
D) Declaring instance variables public is known as data hiding or information hiding.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following statements is true?

A) Each object (instance) of the class shares the class's instance variables.
B) Most instance-variable declarations are preceded with the keyword public, which is an access modifier.
C) Variables or methods declared with access modifier private are accessible only to methods of the class in which they're declared.
D) None of the above is true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following statements is false?

A) By convention class names begin with an uppercase letter, and method and variable names begin with a lowercase letter.
B) Instance variables exist before methods are called on an object, while the methods are executing and after the methods complete execution.
C) A class normally contains one or more methods that manipulate the instance variables that belong to particular objects of the class.
D) Instance variables can be declared anywhere inside a class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
20
You can declare new classes as needed; this is one reason Java is known as a(n) ________ language.

A) portable
B) incremental
C) extensible
D) virtual
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following statements is true?

A) Constructors can specify parameters and return types.
B) Constructors can specify parameters but not return types.
C) Constructors cannot specify parameters but can specify return types.
D) Constructors can specify neither parameters nor return types.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following statements is false?

A) A floating-point number is a number with a decimal point.
B) Java provides two primitive types for storing floating-point numbers in memory-float and double.
C) Variables of type float represent single-precision floating-point numbers and have seven significant digits.
D) Variables of type double represent double-precision floating-point numbers; these require twice as much memory as float variables and provide 14 significant digits.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
23
A __________ of a class called MyClass is another class whose methods call the methods of MyClass.

A) consumer
B) servant
C) caller
D) client
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
24
The format specifier %.2f specifies that two digits of precision should be output ________ in the floating-point number.

A) to the left of the decimal point
B) centered
C) to the right of the decimal point
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
25
The format specifier ________ is used to output values of type float or double.

A) %f
B) %d
C) %fd
D) %r
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
26
Which of the following statements is false?

A) A primitive-type variable can store exactly one value of its declared type at a time.
B) Primitive-type instance variables are initialized by default.
C) Variables of types byte, char, short, int, long, float and double are initialized to 0.
D) Variables of type boolean are initialized to true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which of the following statements is false?

A) If a class does not define constructors, the compiler provides a default constructor with no parameters.
B) If you declare a constructor for a class, the compiler will not create a default constructor for that class.
C) The UML models constructors in the third compartment of a class diagram.
D) To distinguish a constructor from a class's operations, the UML places the word "constructor" between double quotes before the constructor's name.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
28
Floating-point literals are of type ________ by default.

A) float
B) double
C) real
D) decimal
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
29
Reference-type variables (called references) store ________ in memory.

A) the value of an object
B) a copy of an object
C) the location of an object
D) the size of an object
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which of the following statements is false?

A) A reference to an object is required to invoke an object's methods.
B) A primitive-type variable does not refer to an object.
C) Reference-type instance variables are initialized by default to the value void.
D) A primitive-type variable cannot be used to invoke a method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
31
If a class does not define constructors, the compiler provides a default constructor with no parameters, and the class's instance variables are initialized to ________.

A) zero
B) null
C) their default values.
D) false
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
32
Types in Java are divided into two categories. The primitive types are boolean, byte, char, short, int, long, float and double. All other types are ________ types.

A) static
B) reference
C) declared
D) source
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 32 في هذه المجموعة.