Java Likely Examination Questions and Past Questions with Answers

 


Java Likely  Quizzes, Examination Questions and Answers


 

1.  What is the output of this code?

 

       int x,y;                

        x = 60;       

        y  = x;

   System.out.print("xd");

   System.exit(x);

   System.out.print(y);

ANSWER:    xd

 

2. Which operator terminates the statement in Java?

            Select one:

a. (semicolon);

b.  (colon):

c.  (dot operator).

d. (comma),

ANSWER:   A

 

3. What is the value of the variable "result"?       

     double c = 3.0;

        double result;

        result = 4 + --c;

    Select one:

        a. 1.0

        b. 7.0

        c. 6.0

        d. 7

 

        ANSWER:   C

 

4. This statement below makes PI constant 

    final double PI = 3.142; 

    Select one:

    a. True

    b. False

ANSWER:   True

 

5. By default, the class members are ...

    Select one: 

        a. Package private

        b. protected 

        c. private

        d. public

    ANSWER:   A

6. Which lines of code print out "java" and move to the next line?

    Select one or more:

    a.      System.out.print("java/n");

    b.     System.out.printf("%s%n", "java");

    c.      System.out.println("java");

    d.     System.out.printf("%s\n","java");

 

ANSWER:   B, C, D

 

7. What is the output of this code?

        String str1 = "switch bell";

        String str2 = str1.replaceAll("bell","on");

        Select one:

        System.out.print(str2);


        a.      Compilation Error

        b.     switch on bell

        c.      switch bell on

        d. switch on


   ANSWER:    D

 

8. What is the output of this code?

        int x = 13; 

        int y = 3;

        System.out.println(x / y % 3);


    ANSWER:    1

 

9. What is the output of the expression below?

            System.out.print( 

            "abc" 

            substring(1,3)

            );


    ANSWER:    bc

 

10. Which of the following is a valid declaration of a variable X of type int?

        Select one or more:

        a. int X = -6;

        b. int X = 159.5;

        c. int X = 34;

        d.     int X = -100.6;

 ANSWER:    A, C

 


More Java questions will be added in the near future......... 
Continue to visit the page or click like and subscribe to receive updates on new posts here.





--------------------------------------------------------------------------------------------------------

We appreciate you visiting our questions and answers in this blog! I sincerely hope the details were useful. If you have any other information or believe I may have missed something crucial, kindly let us know in the comments area below. As always, feel free to share the link to this article on your social media platforms. Also, don't forget to subscribe to our Telegram channel and like our Facebook and other media pages to show your support!


If you have any questions, then you should join our Telegram chat group. We will help you solve your problems with blogging and SEO.

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.