Skip to main content

Section 4 Oracle Java Fundamental Quiz

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 (*)

Comments

  1. Keren, makasih atas ilmu bermanfaat nya

    ReplyDelete

  2. Thank you for sharing this Oracle Java Fundamental Quiz. It's great to see quizzes like this that can test and reinforce knowledge of Java fundamentals. Quizzes are a valuable tool for developers to assess their understanding of the language and identify areas where they can further improve.
    To know more about java then Best Java Training in Indore is the right place for learning.

    ReplyDelete
  3. I appreciate you providing this Oracle Java Fundamental Quiz. It's fantastic to have quizzes available that can effectively evaluate and reinforce one's grasp of Java fundamentals. Quizzes serve as a valuable resource for developers to gauge their knowledge of the language and pinpoint specific areas for further enhancement. If you're seeking a platform to expand your understanding of Java, the Best Java Training course in Bhopal offers an ideal learning environment.

    ReplyDelete
  4. "Your article made my day! I found it incredibly insightful and well-written. I'll definitely be coming back for more. Students can also explore best online Java course in Hisar to enhance their career prospects and gain valuable skills in the field.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Great work it's helpme a lot for doing my college project. Doing this a more confident thankyou . With a focus on practicality, aspiring Unlocking the power of Data Science will discover a myriad of career options and abundant learning resources available to embark on this exciting journey.

    ReplyDelete

Post a Comment

Popular posts from this blog

Section 6 Quiz Oracle Database Programming with SQL

Section 6 Quiz             (Answer all questions in this section)                                                             1.         Given the following descriptions of the employees and jobs tables, which of the following scripts will display each employee ï¾’ s possible minimum and maximum salaries based on their job title? EMPLOYEES Table: Name   Null?    Type EMPLOYEE_ID          NOT NULL     NUMBER (6) FIRST_NAME             VARCHAR2 (20) LAST_NAME  NOT NULL     VARCHAR2 (25) EMAIL NOT NULL     VARCHAR2 (25) PHONE_NUMBER                  VARCHAR2 (20) HIRE_DATE   NOT NULL     DATE JOB_ID           NOT NULL     VARCHAR2 (10) SALARY                     NUMBER (8,2) COMMISSION_PCT                NUMBER (2,2) MANAGER_ID                       NUMBER (6) DEPARTMENT_ID                 NUMBER (4) JOBS Table: Name   Null?    Type JOB_ID           NOT NULL     VARCHAR2 (10) JOB_TITLE     NOT NULL     VARCHAR2 (35) MIN_SALARY                      

Section 10 Quiz Database Programming With SQL

Section 10 Quiz             (Answer all questions in this section) 1.         A multiple-row operator expects how many values?   Mark for Review (1) Points             One or more (*)             Only one             Two or more             None 2.         The salary column of the f_staffs table contains the following values: 4000 5050 6000 11000 23000 Which of the following statements will return the last_name and first_name of those employees who earn more than 5000?  Mark for Review (1) Points             SELECT last_name, first_name FROM f_staffs WHERE salary IN (SELECT last_name, first_name FROM f_staffs WHERE salary <5000 o:p="">             SELECT last_name, first_name FROM f_staffs WHERE salary = (SELECT salary FROM f_staffs WHERE salary < 5000);             SELECT last_name, first_name FROM f_staffs WHERE salary IN (SELECT salary FROM f_staffs WHERE salary > 5000); (*)             SELEC

Section 2 Quiz Database Design Oracle

Section 2 Quiz             (Answer all questions in this section) 1.         An Entity Relationship model is independent of the hardware or software used for implementation. True or False?  Mark for Review (1) Points             True (*)             False 2.         A well structured ERD will show only some parts of the finished data model. You should never try to model the entire system in one diagram, no matter how small the diagram might be. True or False?           Mark for Review (1) Points             True             False (*) 3.         The purpose of an ERD is to document the proposed system and facilitate discussion and understanding of the requirements captured by the developer. True or False?          Mark for Review (1) Points             True (*)             False 4. Documenting Business Requirements helps developers control the scope of the system and prevents users from claiming that the new system does not meet their business req