Java - Quiz

42 Questions | Attempts: 300
Share
SettingsSettings
Please wait...
  • 1/42 Questions

    What is Java (in regard to Computer Science) ?

    •  A type of coffee
    • AN OBJECT-ORIENTED PROGRAMMING LANGUAGE
Please wait...
About This Quiz

Test your Java Skills.

Java Quizzes & Trivia

Quiz Preview

  • 2. 

    WHAT IS AN APPLET?

    • A JAVA PROGRAM THAT IS RUN THROUGH A WEB BROWSER

    •  A type of coffee

    Correct Answer
    A. A JAVA PROGRAM THAT IS RUN THROUGH A WEB BROWSER
  • 3. 

    What is a function in terms of Computer Science ?

    •  A group of code lines that performs a specific task

    •  Something that contains an ‘init’

    Correct Answer
    A.  A group of code lines that performs a specific task
  • 4. 

    Java runs on _______.

    •  Windows

    • All of the Above

    •  Unix/Linux

    Correct Answer
    A. All of the Above
  • 5. 

     If you want your conditional to depend on two conditions BOTH being true, what is the proper notation to put between the two Boolean statements ?

    • &&

    • !!

    Correct Answer
    A. &&
  • 6. 

     What is a loop ?

    •  A new type of Applet

    •  A segment of code to be run a specified amount of times

    Correct Answer
    A.  A segment of code to be run a specified amount of times
  • 7. 

    What does AWT stands for ?

    •  Abstract window Toolkit

    •  Adjust Window Toolkit

    Correct Answer
    A.  Abstract window Toolkit
  • 8. 

     Booleans are _______.

    •  True or False

    •  Single characters

    Correct Answer
    A.  True or False
  • 9. 

    Following code will result in: int a = 3.5;

    • Compilation error

    • Runtime error

    Correct Answer
    A. Compilation error
  • 10. 

    Synchronized is a keyword to tell a Thread to grab an Object lock before continuing execution.

    • True

    • False

    Correct Answer
    A. True
  • 11. 

    What is the main function of any variable ?

    •  To add numbers together

    •  To keep track of data in the memory of the computer

    Correct Answer
    A.  To keep track of data in the memory of the computer
  • 12. 

    What is an assignment statement ?

    • Assigning a name to a variable

    • Assigning a value to a variable

    Correct Answer
    A. Assigning a value to a variable
  • 13. 

    An abstract class can have non-abstract methods

    • True

    • False

    Correct Answer
    A. True
  • 14. 

    Primitive datatypes are allocated on a stack

    • True

    • False

    Correct Answer
    A. True
  • 15. 

    Methods that are marked protected can be called in any subclass of that class.

    • True

    • False

    Correct Answer
    A. True
  • 16. 

    What is the proper way to declare a variable ?

    • VariableName variableType;

    • VariableType variableName;

    Correct Answer
    A. VariableType variableName;
  • 17. 

    What's the difference between an Applet and an application ?

    • Applets can paint words, applications cannot.

    •  Applets are run over the web.

    Correct Answer
    A.  Applets are run over the web.
  • 18. 

    Inner classes can be defined within methods

    • True

    • False

    Correct Answer
    A. True
  • 19. 

    What is essential in making sure that your loop is not infinite ?

    • That there is a Boolean statement somewhere in your code

    • That your Boolean statement will at some point be false

    Correct Answer
    A. That your Boolean statement will at some point be false
  • 20. 

    The methods wait(), notify() and notifyAll() in Object need to be called from synchronized pieces of code.

    • True

    • False

    Correct Answer
    A. True
  • 21. 

    Following code will result in: float a = 9/0

    • Compilation error: DivideByZeroException

    • Runtime Exception

    Correct Answer
    A. Runtime Exception
  • 22. 

    How can you prevent a member variable from becoming serialized?

    • By marking it volatile

    • By marking it transient

    Correct Answer
    A. By marking it transient
  • 23. 

    Which of the following means that in order for the conditional to happen, either x must be less than 3 or y must be greater than or equal to 4 ?

    •  if ((x < 3) || (y > = 4))

    •  if ((x > 3) || (y < = 4))

    Correct Answer
    A.  if ((x < 3) || (y > = 4))
  • 24. 

     Following code will result in: int a = 9/0;

    • Compilation error: Divisions must be in a try block.

    • Runtime Exception

    Correct Answer
    A. Runtime Exception
  • 25. 

    Following code will result in: class A { int b = 1; public static void main(String [] args) { System.out.println("b is " + b); }}

    • Compilation error

    • Runtime Error

    Correct Answer
    A. Compilation error
  • 26. 

    In a ‘for’ loop, what section of the loop is not included in the parentheses after “for” ?

    •  Loop Body

    •  Initialization

    Correct Answer
    A.  Loop Body
  • 27. 

    What is an instanceof

    • A methods in object

    • An operator and keyword

    Correct Answer
    A. An operator and keyword
  • 28. 

     A class cannot be declared

    • Static

    • Private

    Correct Answer
    A. Private
  • 29. 

    If class A implements an interface does it need to implement all methods of that interface?

    • Yes, always

    • No, not when A is abstract

    Correct Answer
    A. No, not when A is abstract
  • 30. 

    What is the size of a Char?

    • 4 bits

    • 7 bits

    • 8 bits

    • 16 bits

    Correct Answer
    A. 16 bits
  • 31. 

    Can you compare a boolean to an integer?

    • Yes

    • No

    Correct Answer
    A. No
  • 32. 

    Which is NOT a section of all types of loops ?

    •  Test statement

    •  The word "while"

    Correct Answer
    A.  The word "while"
  • 33. 

    Following code will result in: int a1 = 5; double a2 = (float)a1;

    • Runtime error

    • No errors

    Correct Answer
    A. No errors
  • 34. 

    Following code will result in: class A { public static void main(String [] args) {A a = new B(); }} class B extends A {}

    • Runtime Exception

    • No errors

    Correct Answer
    A. No errors
  • 35. 

    Why can't the whole program just consist of the one line that does the painting ?

    • In Java, to create an applet, you can't call on functions without defining a class to call them.

    • The drawString function is not defined without the "import" statements at the top.

    •  All of the above.

    Correct Answer
    A.  All of the above.
  • 36. 

    Java keywords are written in lowercase as well as uppercase

    • True

    • False

    Correct Answer
    A. True
  • 37. 

    A class can be transient

    • True

    • False

    Correct Answer
    A. False
  • 38. 

    What will be the value of “num” after the following statements?

    • 1

    • 12

    Correct Answer
    A. 12
  • 39. 

    The following statements make “length” be what number ?

    •  5

    • 6

    Correct Answer
    A.  5
  • 40. 

    Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if (a==b)?

    • True

    • FALSE

    Correct Answer
    A. FALSE
  • 41. 

    Following code will result in: class A { public static void main(String [] args) {A a = new B(); }} class B extends A {}

    • Compile error

    • No error

    Correct Answer
    A. Compile error
  • 42. 

    The default statement of a switch is always executed

    • True

    • False

    Correct Answer
    A. False

Quiz Review Timeline (Updated): Feb 14, 2014 +

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

  • Current Version
  • Feb 14, 2014
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 24, 2013
    Quiz Created by
    Dbhacker9988
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.