Computer Science Java Quiz

23 Questions | Total Attempts: 519

Settings
Please wait...
Computer Science Java Quiz

.


Questions and Answers
  • 1. 
    Refer to the following variable declaration for this question: int[] numbers = {1,2,3,4,5,6,7,8,9,10}; Which of the following is a valid conclusion based on this variable declaration?
    • A. 

      Int[8] numbers = 9;

    • B. 

      Numbers[2] = 2;

    • C. 

      Int[9] numbers = 10;

    • D. 

      Numbers[5] = 6;

    • E. 

      Both a and c

  • 2. 
    Refer to the following variable declaration for this question: double[] decimals = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0}; What does this variable declaration represent?
    • A. 

      A package

    • B. 

      A list

    • C. 

      An iteration

    • D. 

      An integer

    • E. 

      None of the above

  • 3. 
    When should one choose a for() loop instead of a while() loop?
    • A. 

      When you have multiple conditions

    • B. 

      When a condition will end the loop

    • C. 

      When you know the number of times the loop should execute

    • D. 

      When you are performing a specific java function

    • E. 

      None of the above

  • 4. 
    When running any java class, which of the following is the starting point?
    • A. 

      The method header

    • B. 

      The class header

    • C. 

      The main() method

    • D. 

      My_first_method()

    • E. 

      None of the above - not enough information is given

  • 5. 
    Each time that a loop "loops" is known as a(n):
    • A. 

      Index

    • B. 

      Count

    • C. 

      Increment

    • D. 

      Iteration

    • E. 

      None of these choices

  • 6. 
    Which of the following most specifically defines a package?
    • A. 

      A group of java classes with a similar purpose

    • B. 

      A group of java objects

    • C. 

      A group of java methods with a similar purpose

    • D. 

      A series of code blocks

    • E. 

      A list of parameters

  • 7. 
    Which of the following is an example of a method header?
    • A. 

      Public void drawRectangle();

    • B. 

      Public static int stringToInteger()

    • C. 

      Public static calculateGCF()

    • D. 

      DrawSquare(int scale);

    • E. 

      All of the above

  • 8. 
    An overloaded method is:
    • A. 

      A method with an undefined type

    • B. 

      A method with too many parameters

    • C. 

      A method with the same name, but different parameters

    • D. 

      A method called inside an infinite loop

    • E. 

      A method with a syntax error

  • 9. 
    Which of the following is an example of a call to a method to draw a rectangle that is 100 by 200 pixels?
    • A. 

      Public void drawRectangle(100, 200);

    • B. 

      DrawRectangle(100, 200);

    • C. 

      Public void drawRectangle(int length, int width);

    • D. 

      Public void drawRectangle(100, 200)

    • E. 

      DrawRectangle(100, 200)

  • 10. 
    Which of the following data types are ideal for numbers?
    • A. 

      Float

    • B. 

      Boolean

    • C. 

      Char

    • D. 

      Double

    • E. 

      Both a and d

  • 11. 
    Which of the following would be an example of only instantiating an object?
    • A. 

      Turtle george = new Turtle();

    • B. 

      George = new Turtle();

    • C. 

      Turtle george;

    • D. 

      Turtle = new Turtle(george);

    • E. 

      None of the above

  • 12. 
    Which of the following would be an example of only declaring a number variable?
    • A. 

      Double number;

    • B. 

      Int number = 4;

    • C. 

      Float number = new float;

    • D. 

      None of the above

  • 13. 
    Pseudocode is:
    • A. 

      A formal programming language

    • B. 

      Written after you have designed your program

    • C. 

      Used by programmers to help map out what a program is supposed to do

    • D. 

      Actual code which can be easily altered

    • E. 

      None of the above

  • 14. 
    Which of the following is an example of a constructor?
    • A. 

      Public class void SimpleTurtle

    • B. 

      Public static int calculateGCF

    • C. 

      Protected class Robot;

    • D. 

      Private class Calculator

    • E. 

      None of the above

  • 15. 
    • A. 

      HelloWorld.java

    • B. 

      HelloWorld.java

    • C. 

      Class HelloWorld.java

    • D. 

      Public class HelloWorld.java

    • E. 

      None of the above

  • 16. 
    • A. 

      A driver class

    • B. 

      A driving class

    • C. 

      An automatic class

    • D. 

      A stand-alone class

    • E. 

      None of the above

  • 17. 
    Following proper method naming conventions, which of the following would be a good method constructor?
    • A. 

      Public static void drawSquare();

    • B. 

      Private static int CalculateLCM()

    • C. 

      Public void calculateNumberOfFactors()

    • D. 

      Private void drawRectangle();

    • E. 

      None of the above

  • 18. 
    Which of the following would be used to import all the classes in the java.awt class?
    • A. 

      Import java.util.*;

    • B. 

      Import java.awt.%;

    • C. 

      Import java.awt;

    • D. 

      Import java.awt.*;

    • E. 

      None of the above

  • 19. 
    What is the use of the java.awt package?
    • A. 

      For mainly allowing user-input to show up on the screen.

    • B. 

      Creating user interfaces and for painting graphics and images.

    • C. 

      To perform math functions such as multiplication or addition.

    • D. 

      To determine the age of an individual based on the Gregorian calender

    • E. 

      None of the above

  • 20. 
    Which of the following classes is included in the java.util package?
    • A. 

      Color

    • B. 

      Image

    • C. 

      Scanner

    • D. 

      Graphics2D

    • E. 

      A,b and d

  • 21. 
    Which of the following best describes a contructor method?
    • A. 

      A normal public method

    • B. 

      A public method that shares the same name as the class, but cannot return a value

    • C. 

      A private method which can only be performed if the user types in a password

    • D. 

      A normal private method

    • E. 

      None of the above

  • 22. 
    Given the Turtle object t1, how can you call a method to make it move forward 100 pixels, using a distance parameter?
    • A. 

      T1-forward();

    • B. 

      T1.backward(-);

    • C. 

      T1_forward(100);

    • D. 

      T1.backward(-100);

    • E. 

      None of the above

  • 23. 
    Which of the following is not a primitive data type?
    • A. 

      String

    • B. 

      Int

    • C. 

      Double

    • D. 

      Char

    • E. 

      None of the above