https://www.idblanter.com/search/label/Template
https://www.idblanter.com
BLANTERORBITv101

Section 4 Oracle Java Fundamental Quiz

Jumat, 03 November 2017
Section 4 Quiz
(Answer all questions in this section)


1. What will the following code segment output?


Mark for Review
(1) Points
"\\" (*)
"\\\"
\"\\\\\"
"\\\\\"


2. The String methods equals and compareTo perform similar functions and differ in their return type. True or false? Mark for Review
(1) Points
True (*)
False


3. Consider the following code snippet. What is printed?


String river = new String("Hudson"); System.out.println(river.length()); Mark for Review
(1) Points
8
7
Hudson
river
6 (*)


4. Which of the following defines a driver class? Mark for Review
(1) Points
Contains a main method and other static methods. (*)
Contains classes that define objects.
Contains a main method, a package, static methods, and classes that define objects.
None of the above.


5. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.


6. Which of the two diagrams below illustrate the general form of a Java program?






Mark for Review

(1) Points
Example A
Example B (*)


7. When importing another package into a class you must import only the package classes that will be called and not the entire package. True or false? Mark for Review
(1) Points
True
False (*)


8. What two values can a boolean variable have? Mark for Review
(1) Points
Relational and logic operators
Arithmetic and logic operators
True and false (*)
Numbers and characters
Integers and floating point types


9. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review
(1) Points
int a=Math.pow(5,8);
double a=Math.pow(5,8); (*)
double a=15^8;
int a=Math.pow(8,5);
double a=pow(8,5);


10. What is the output of the following lines of code?


int j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result); Mark for Review
(1) Points
-42
2 (*)
6
0



11. What will the method methodA print to the screen?



Mark for Review
(1) Points
15
6
3
18 (*)


12. Write a declaration statement that will hold a number like 2.541. Mark for Review
(1) Points
float number; (*)
boolean number;
char number;
int number;


13. For every opening curly brace { there must be a closing curly brace} or the program will not compile without error. True or False? Mark for Review
(1) Points
True (*)
False


14. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? Mark for Review
(1) Points
Close
Edit
File
Help (*)


15. Tabs are used when more than one file is open in the edit area. True or False? Mark for Review
(1) Points
True (*)
False


1. Consider the following:


You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable.


This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name.


True or false? Mark for Review
(1) Points
True
False (*)


2. Which of the following statements correctly assigns "3 times 10 to the 4th power" to the variable number? Mark for Review
(1) Points
double number=3(e4);
double number=3*10e4;
double number=3*10^4;
double number=3e4; (*)


3. Which line of code does not assign 3.5 to the variable x? Mark for Review
(1) Points
3.5=x; (*)
x=7.0/2.0;
double x=3.5
x=3.5;


4. A local variable has precedence over a global variable in a Java method. True or false? Mark for Review
(1) Points
True (*)
False


5. What does the following program output?




Mark for Review

(1) Points
"total cost: " 48
total cost: 48
"total cost: " 40
total cost: + 40
total cost: 40 (*)


6. For every opening curly brace { there must be a closing curly brace} or the program will not compile without error. True or False? Mark for Review
(1) Points
True (*)
False


7. The ______________ is the location into which you will store and save your files. Mark for Review
(1) Points
Perspective
Workspace (*)
Editor
None of the above


8. What symbols are required for a compiler to ignore a comment? Mark for Review
(1) Points
/*/
/*
*/
// (*)


9. The following program prints "Equal". True or false?




Mark for Review
(1) Points
True
False (*)


10. Suppose that s1 and s2 are two strings. Which of the statements or expressions are valid? Mark for Review
(1) Points
(Choose all correct answers)
String s3 = s1 + s2; (*)
String s3 = s1 - s2;
s1.compareTo(s2); (*)
int m = s1.length(); (*)
s1 <= s2


11. Declaring and instantiating a String is much like any other type of variable. However, once instantiated, they are final and cannot be changed. True or false? Mark for Review
(1) Points
True (*)
False


12. The following defines a package keyword: Mark for Review
(1) Points
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class.


13. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.


14. The following defines a class keyword: Mark for Review
(1) Points
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.
Provides the compiler information that identifies outside classes used within the current class.


15. When importing another package into a class you must import the entire package as well as the package classes that will be called. True or False? Mark for Review
(1) Points
True
False (*)


1. Match each of the following literals ('x', 10, 10.2, 100L, "hello") with its respective data type. Mark for Review
(1) Points
char, boolean, float, long, String
char, double, int, long, String
char, int, long, float, String
boolean, byte, int, long, Short
char, int, double, long, String (*)


2. Which line of Java code will assign the value of the square root of 11 to a variable named a? Mark for Review
(1) Points
int a=Math.sqrt(11);
double a=11^(1/2);
double a=Math.sqrt*11;
double a=Math.sqrt(11); (*)
double a=sqrt(11);


3. Which of the following statements displays 12345?


I. System.out.println( 123 * 100 + 45);
II. System.out.println("123" + 45);
III. System.out.println( 12 + "345"); Mark for Review
(1) Points
All of the above. (*)
I only.
I and II only.
II and III only.
None of the above.


4. Consider the following:


You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable.


This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name.


True or false? Mark for Review
(1) Points
True
False (*)


5. Select the declaration and initialization statement that will hold the letter J. Mark for Review
(1) Points
String letter='J';
char letter='J'; (*)
int letter='J';
float letter='J';


6. For every opening curly brace { there does not need to be a closing curly brace} for the program to compile without error. True or False? Mark for Review
(1) Points
True
False (*)


7. Two variables are required to support a conversion of one unit of measure to another unit of measure. True or False? Mark for Review
(1) Points
True (*)
False


8. Eclipse provides views to help you navigate a hierarchy of information. True or False? Mark for Review
(1) Points
True (*)
False


9. The == operator can be used to compare two String objects. The result is always true if the two strings are identical. True or false? Mark for Review
(1) Points
True
False (*)


10. Consider the following code snippet


String forest = new String("Black");
System.out.println(forest.length());


What is printed? Mark for Review
(1) Points
Forest
7
6
Black
5 (*)


11. The following program prints "Equal". True or false?


Mark for Review
(1) Points
True (*)
False


12. The following defines a package keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Precedes the name of the class.



13. Which of the two diagrams below illustrate the general form of a Java program?



Mark for Review
(1) Points
Example A
Example B (*)


14. Which of the two diagrams below illustrate the general form of a Java program?



Mark for Review
(1) Points
Example A
Example B (*)


15. Which of the following defines a driver class? Mark for Review
(1) Points
Contains a main method and other static methods. (*)
Contains classes that define objects.
Contains a main method, a package, static methods, and classes that define objects.
None of the above.


1. In Eclipse, when you run a Java Application, the results are displayed in a new window. True or False? Mark for Review
(1) Points
True
False (*)


2. Multiple windows are used when more than one file is open in the edit area. True or False? Mark for Review
(1) Points
True
False (*)


3. What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points
(Choose all correct answers)
To choose the file system location to delete a file.
To modify elements. (*)
To navigate a hierarchy of information. (*)


4. The following defines an import keyword: Mark for Review
(1) Points
Precedes the name of the class.
Defines where this class lives relative to other classes, and provides a level of access control.
Provides the compiler information that identifies outside classes used within the current class. (*)


5. The following defines a package keyword: Mark for Review
(1) Points
Precedes the name of the class.
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)


6. The following defines a class keyword: Mark for Review
(1) Points
Defines where this class lives relative to other classes, and provides a level of access control.
Precedes the name of the class. (*)
Provides the compiler information that identifies outside classes used within the current class.


7. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control.
Precedes the name of the class. (*)


8. The following code is an example of creating a String reference:


String s;


True or false? Mark for Review
(1) Points
True (*)
False


9. Which of the following statements declares a String object called name? Mark for Review
(1) Points
String name; (*)
String name
double name;
int name;


10. Given the code below, which of the following would equate to true?


String s1 = "yes";
String s2 = "yes";
String s3 = new String(s1);
Mark for Review
(1) Points

(Choose all correct answers)
s1 == s2 (*)
s3.equals(s1) (*)
s1.equals(s2) (*)
s1 = s2
s3 == s1


11. Which line of Java code will assign the value of the square root of 11 to a variable named a? Mark for Review
(1) Points
double a=11^(1/2);
double a=sqrt(11);
double a=Math.sqrt(11); (*)
double a=Math.sqrt*11;
int a=Math.sqrt(11);


12. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review
(1) Points
int a=Math.pow(5,8);
int a=Math.pow(8,5);
double a=pow(8,5);
double a=15^8;
double a=Math.pow(5,8); (*)


13. Which line of Java code properly calculates the area of a triangle using A=1/2(b)(h) where b and h are Java primitive integers? Mark for Review
(1) Points
double A=1/2bh;
double A=(double)1/(double)2*b*h; (*)
double A=(double)(1/2)*b*h;
double A=1/2*b*h;


14. What is the output of the following lines of code?


int j=7,k=5,m=8,result;
result=j/m*k;
System.out.println(result); Mark for Review
(1) Points
0.175
280
4.375
0 (*)


15. Which of the following is not a legal name for a variable? Mark for Review
(1) Points
theLastValueButONe
zero
year2000
2bad (*)


1. What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points
(Choose all correct answers)
To modify elements. (*)
To choose the file system location to delete a file.
To navigate a hierarchy of information. (*)


2. A _______________ is used to organize Java related files. Mark for Review
(1) Points
Project
Collection
Package (*)
Workspace


3. A workspace can have one or more stored projects. True or false? Mark for Review
(1) Points
True (*)
False


4. Which of the two diagrams below illustrate the general form of a Java program?





Mark for Review
(1) Points
Example A
Example B (*)


5. The following defines a class keyword: Mark for Review
(1) Points
Precedes the name of the class. (*)
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control.


6. The following defines a package keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Precedes the name of the class.


7. Which of the two diagrams below illustrate the general form of a Java program?




Mark for Review
(1) Points
Example A
Example B (*)


8. Examine the following code:





What is the value of variable x? Mark for Review
(1) Points
14
2 (*)
6
2.5


9. Which of the following is not correct Java code? Mark for Review
(1) Points
double x=Math.pow; (*)
double x=Math.sqrt(16);
double x=Math.pow(3,4)*5.0;
double x=Math.PI*5.0;


10. What is the output of the following lines of code?


int j=7,k=5,m=8,result;
result=j/m*k;
System.out.println(result); Mark for Review
(1) Points
0.175
280
4.375
0 (*)


11. What is the output of the following lines of code?


int j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result); Mark for Review
(1) Points
-42
0
2 (*)
6


12. What two values can a boolean variable have? Mark for Review
(1) Points
Arithmetic and logic operators
Integers and floating point types
Numbers and characters
Relational and logic operators
True and false (*)



13. What is printed by the following code segment?





Mark for Review
(1) Points
\\\\\\\\\\\\\\
\\\\
\\\\\\\ (*)
\\


14. Declaring and instantiating a String is much like any other type of variable. However, once instantiated, they are final and cannot be changed. True or false? Mark for Review
(1) Points
True (*)
False


15. Consider the following code snippet.









What is printed? Mark for Review
(1) Points
AtlanticPacificIndianArcticSouthern
Code does not compile
87658
55555

ArrayIndexOutofBoundsException is thrown (*)

Author

Hestech Indonesia

Innovasi di bidang Teknologi, Listrik, Teknik Komputer dan gaya Hidup. Info lainnya tentang praktik konservasi berbasis Sains, inovasi, dan kearifan lokal