Intro To Java

42 Questions | Attempts: 228
Share

SettingsSettingsSettings
Java Quizzes & Trivia

Java Script test


Questions and Answers
  • 1. 

    Another term for program is:

    • A.

      Peopleware

    • B.

      Hardware

    • C.

      Software

    • D.

      Firmware

    Correct Answer
    C. Software
  • 2. 

    The major components of a typical computer system consist of

    • A.

      Input/output devices

    • B.

      Main memory

    • C.

      Secondary Storage

    • D.

      The CPU

    • E.

      All of the above

    Correct Answer
    E. All of the above
  • 3. 

    A byte is a collection of

    • A.

      Four bits

    • B.

      A dollar

    • C.

      Six bits

    • D.

      Eight bits

    Correct Answer
    D. Eight bits
  • 4. 

    A(n)______________is a special programming language used to write computer programs.

    • A.

      Programming language

    • B.

      Application

    • C.

      Operating system

    • D.

      Application

    • E.

      Pseudocode

    Correct Answer
    A. Programming language
  • 5. 

    Syntax is

    • A.

      Words that have a special meaning in the programming language

    • B.

      Rules that must be followed when writing a program

    • C.

      Symbols or words that perform operations

    • D.

      Punctuation

    Correct Answer
    B. Rules that must be followed when writing a program
  • 6. 

    Variables are:

    • A.

      Symbolic names made up by the programmer whose values cannot be changed

    • B.

      Operators that perform operations on one or more operands

    • C.

      Symbolic names made up by the programmer that represent locations in the computers RAM

    • D.

      Reserved words

    Correct Answer
    C. Symbolic names made up by the programmer that represent locations in the computers RAM
  • 7. 

    A software entity that contains data and procedures is a(n)

    • A.

      Object

    • B.

      Method

    • C.

      Class

    • D.

      Program

    Correct Answer
    A. Object
  • 8. 

    RAM is usually

    • A.

      Secondary storage

    • B.

      A volatile type of memory, used only for temporary storage

    • C.

      A static type of memory, used only for temporary storage

    • D.

      A static type of memory, used for permanent storage

    • E.

      An input/output device

    Correct Answer
    B. A volatile type of memory, used only for temporary storage
  • 9. 

    A computer program is

    • A.

      Pseudocode

    • B.

      Main memory

    • C.

      A set of instructions that enable the computer to solce a problem or perform a task

    • D.

      A flow chart

    Correct Answer
    C. A set of instructions that enable the computer to solce a problem or perform a task
  • 10. 

    Key words are

    • A.

      Words or names defined by a programmer

    • B.

      Symbols or words that perform operations on one or more operands

    • C.

      Words that have a special meaning in the programming language

    • D.

      The data names in your program

    Correct Answer
    C. Words that have a special meaning in the programming language
  • 11. 

    _________ are used to indicate the end of a Java statement

    • A.

      Periods

    • B.

      Semicolons

    • C.

      Colons

    • D.

      Asterisks

    Correct Answer
    B. Semicolons
  • 12. 

    If the following Java statements are executed, what will be displayedSystem.out.println("The top three winners are \n");System.out.println("Jody, the Giant \n");System.out.print("Buffy, the Dwarf");System.out.print("Adelle, the Albino");

    • A.

      The top three winners are Jody, the Giant Buffy, the DwarfAdelle, the Albino

    • B.

      The top three winners are Jody, the Giant\nBuffy, the DwarfAdelle, the Albino

    • C.

      The top three winnders are Jody, the Giant\nBuffy, the DwarfAdelle, the Albino

    • D.

      The top three winnders are Jody, the Giant Buffy, the Dwarf Adelle, the Albino

    Correct Answer
    A. The top three winners are Jody, the Giant Buffy, the DwarfAdelle, the Albino
  • 13. 

    A(n) _______ is a value that is written into the code of a program

    • A.

      Assignment statement

    • B.

      Variable

    • C.

      Literal

    • D.

      Operator

    Correct Answer
    C. Literal
  • 14. 

    Which of the following is not a primitive data type?

    • A.

      Float

    • B.

      Short

    • C.

      String

    • D.

      Long

    Correct Answer
    C. String
  • 15. 

    The boolean data type may contain values in the following range of values

    • A.

      -128 to +127

    • B.

      -32,768 to +32,767

    • C.

      -2,198,284 to +2,198,283

    • D.

      True/False

    Correct Answer
    D. True/False
  • 16. 

    Character literals are enclosed in _________; string literals are enclosed in_______.

    • A.

      Double quotes; double quotes

    • B.

      Single quotes; double quotes

    • C.

      Single quotes; single quotes

    • D.

      Double quotes; single quotes

    Correct Answer
    B. Single quotes; double quotes
  • 17. 

    What is the result of the following statement?25/4+4*10%3

    • A.

      19

    • B.

      3

    • C.

      7

    • D.

      5.25

    Correct Answer
    C. 7
  • 18. 

    Which of the following will correctly convert the data type, if x is an integer and y is a double?

    • A.

      X = (int) y;

    • B.

      X=y;

    • C.

      X = int y;

    • D.

      X = y;

    Correct Answer
    A. X = (int) y;
  • 19. 

    In the following Java statement what is the value of the variable, name?

    • A.

      John Doe

    • B.

      The memory address where "John Doe" is located

    • C.

      The memory address where name is located

    • D.

      Name

    Correct Answer
    B. The memory address where "John Doe" is located
  • 20. 

    To display the output on the next line, you can use the println method or use the escape sequence _________, in the print method.

    • A.

      \b

    • B.

      \n

    • C.

      \t

    • D.

      \r

    Correct Answer
    B. \n
  • 21. 

    What would be displayed as a result of the follwing code, assuming x has been declared an integer?x=578;System.out.print("There are " + x + "5 \n" + "hens in the hen house.");

    • A.

      There are 583 hens in the hen house.

    • B.

      There are x5\nhens in the hen house.

    • C.

      There are 5785 hens in the hen house

    • D.

      There are 5785 hens in the hen house.

    Correct Answer
    C. There are 5785 hens in the hen house
  • 22. 

    If x has been declared an integer, int x;, which of the following is invalid?

    • A.

      X=-58932

    • B.

      X=1,000;

    • C.

      X=592;

    • D.

      X=0;

    Correct Answer
    B. X=1,000;
  • 23. 

    Given double r;, which of the following is invalid

    • A.

      R=-9.4632E15;

    • B.

      R=2.9X106

    • C.

      R=9.4632e15;

    • D.

      R=326.75

    Correct Answer
    B. R=2.9X106
  • 24. 

    Variables of the boolean data type are useful for

    • A.

      Working with small integers

    • B.

      Evaluating scientific notation

    • C.

      Evaluating true/false conditions

    • D.

      Working with very large integers

    Correct Answer
    C. Evaluating true/false conditions
  • 25. 

    What is the result of the following statement?17%3*2-12+15

    • A.

      8

    • B.

      7

    • C.

      105

    • D.

      12

    Correct Answer
    B. 7
  • 26. 

    What will be displayed after the following statements have been executed? int x = 15, y = 20, z = 32; x *= y; y –= z; z% = 16; System.out.println(“x = ” + x + “, y = ” + y, “ z = ” +z);

    • A.

      X=300,y=-12,z=0

    • B.

      X=35,y=52,z=48

    • C.

      X=15,y=20,z=32

    • D.

      X=300,y=-12,z=2

    Correct Answer
    A. X=300,y=-12,z=0
  • 27. 

    A(n) ____ is a variable whose content is read only and cannot be changed during the program’s execution of the program.

    • A.

      Named constant

    • B.

      Literal

    • C.

      Operator

    • D.

      Reserved word

    Correct Answer
    A. Named constant
  • 28. 

    Which of the following expressions will check to see if x is less than or equal to y?

    • A.

      X=

    • B.

      X>=y

    • C.

      X

    • D.

      X>y

    Correct Answer
    C. X
  • 29. 

    What will be the value of x after the following code is executed? int x = 75; int y = 60; if (x > y) x = x – y;

    • A.

      75

    • B.

      15

    • C.

      135

    • D.

      60

    Correct Answer
    B. 15
  • 30. 

    What will be the value of ans after the following code has been executed? int x = 65; int y = 55; if (x >= y) int ans = x + y;

    • A.

      10

    • B.

      120

    • C.

      100

    • D.

      No value, there is a syntax error

    Correct Answer
    B. 120
  • 31. 

    What will be the value of ans after the following code has been executed? int x = 90, y = 55, ans = 10; if ( x == y); ans *= 2; a.        10 b.         145 c.         20 d.         No value, there is a syntax error

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    C. C
  • 32. 

    If chr is a character variable, which of the following if statements is correct? a.         if (chr = “a”) b.         if (chr == “a”) c.         if (chr = ‘a’) d.         if (chr == ‘a’)

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    D. D
  • 33. 

    What will be the value of bonus after the following code is executed? int bonus, sales = 10000; if (sales < 5000)             bonus = 200; else if (sales < 7500)             bonus = 500; else if (sales < 10000)             bonus = 750; else if (sales < 20000)             bonus = 1000; else             bonus = 1250; a.         200 b.         500 c.         750 d.         1000 e.         1250

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    • E.

      E

    Correct Answer
    D. D
  • 34. 

    What would be the value of bonus after the following statements are executed? int bonus, sales = 85000; char dept = ‘S’; if (sales > 100000)             if (dept == ‘R’)                         bonus = 2000; else             bonus = 1500; else if (sales > 75000)             if (dept == ‘R’)                         bonus = 1250;             else                         bonus = 1000; else             bonus = 0; a.         2000 b.         1500 c.         1250 d.         1000

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    D. D
  • 35. 

    Which of the following is the correct boolean expression to test for: int x being a value between, but not including, 500 and 650, or int y not equal to 1000? a.         ((x >= 500 && x <= 650) && (y != 1000)) b.         ((x > 500 AND x < 650) OR !(y.equal(1000))) c.         ((x > 500 && x < 650) || (y != 1000)) d.         ((x < 500 && x > 650) || !(y == 1000))

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    C. C
  • 36. 

     The expression in an if statement must evaluate to a.         0 or 1 b.         +1 or –1 c.         true or false d.         T or F

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    C. C
  • 37. 

    27. _____ operators are used to determine whether a specific relationship exists between two values. a.         Arithmetic b.         Relational c.         Syntactical d.         Assignment

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    B. B
  • 38. 

    28. What is the value of x after the following code has been executed? int x = 75; int y = 90; if ( x != y) x += y; a.         75 b.         90 c.         15 d.         165

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    D. D
  • 39. 

    Each byte is assigned to a unique number known as an address.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 40. 

    The following truth table shows various combinations of the values true and false connected by a logical operator. Complete the table by answering T or F to indicate if the result of such a combination is true or false________ true && false________ true && true________ true || false________ false || !false________ !(true && false)________ !(!false)________ !(!true || false)

    Correct Answer
    FTTTTFT
    false true true true true false true
  • 41. 

     A Java program must have at least one a.         Class definition b.         Variable c.         Comment d.         System.out.println(); statement

    • A.

      A

    • B.

      B

    • C.

      C

    • D.

      D

    Correct Answer
    A. A
  • 42. 

    All Java lines of code end with semicolons. a.         True b.         False

    • A.

      A

    • B.

      B

    Correct Answer
    A. A

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jan 15, 2013
    Quiz Edited by
    ProProfs Editorial Team
  • May 07, 2010
    Quiz Created by
    Briitanii
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.