Java Development And Programming Quiz Questions

26 Questions | Attempts: 154
Share

SettingsSettingsSettings
Java Quizzes & Trivia

This test will measure the applicants knowledge and competency in the technical field of Java development and programming


Questions and Answers
  • 1. 

    What is the size of a Char?

    • A.

      4 bits

    • B.

      7 bits

    • C.

      8 bits

    • D.

      16 bits

    Correct Answer
    D. 16 bits
  • 2. 

    A class cannot be declared

    • A.

      Static

    • B.

      Private

    • C.

      Default

    Correct Answer
    B. Private
  • 3. 

    Following code will result in: int a = 3.5;

    • A.

      Compilation error

    • B.

      Runtime error

    • C.

      A being 3.5

    • D.

      A being 3

    Correct Answer
    A. Compilation error
  • 4. 

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

    • A.

      Compilation error

    • B.

      Runtime error

    • C.

      No errors

    Correct Answer
    C. No errors
  • 5. 

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

    • A.

      Compilation error: Divisions must be in a try block

    • B.

      Compilation error: DivideByZeroException

    • C.

      Runtime Exception

    • D.

      No Error: a is NaN

    Correct Answer
    C. Runtime Exception
  • 6. 

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

    • A.

      Compilation error: Divisions must be in a try block

    • B.

      Compilation error: DivideByZeroException

    • C.

      Runtime Exception

    • D.

      No Error: a is NaN

    Correct Answer
    D. No Error: a is NaN
  • 7. 

    A class can be transient

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
  • 8. 

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

    • A.

      Compilation error

    • B.

      Runtime Error

    • C.

      Runtime Exception

    • D.

      Output of b is 1

    Correct Answer
    A. Compilation error
  • 9. 

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

    • A.

      Compile error

    • B.

      Runtime Exception

    • C.

      No error

    Correct Answer
    A. Compile error
  • 10. 

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

    • A.

      Compiler error

    • B.

      Runtime Exception

    • C.

      No errors

    Correct Answer
    C. No errors
  • 11. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 12. 

    An abstract class can have non-abstract methods.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 13. 

    Java keywords are written in lowercase as well as uppercase

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
  • 14. 

    What is an instanceof

    • A.

      A methods in object

    • B.

      An operator and keyword

    Correct Answer
    B. An operator and keyword
  • 15. 

    Primitive datatypes are allocated on a stack.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 16. 

    Can you compare a boolean to an integer?

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
  • 17. 

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

    • A.

      Yes, always

    • B.

      No, not when A is abstract

    Correct Answer
    B. No, not when A is abstract
  • 18. 

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

    • A.

      Compiler error

    • B.

      Runtime Exception

    • C.

      True

    • D.

      False

    Correct Answer
    D. False
  • 19. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
  • 20. 

    Inner classes can be defined within methods.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 21. 

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

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 22. 

    The default statement of a switch is always executed

    • A.

      By marking it private

    • B.

      By marking it volatile

    • C.

      By marking it transient

    • D.

      You can not.

    Correct Answer
    C. By marking it transient
  • 23. 

    Which one does not extend java.lang.Number

    • A.

      Integer

    • B.

      Boolean

    • C.

      Character

    • D.

      Long

    • E.

      Short

    Correct Answer(s)
    B. Boolean
    C. Character
  • 24. 

    What is default layout manager for panels and applets?

    • A.

      Flowlayout

    • B.

      Gridlayout

    • C.

      BorderLayout

    Correct Answer
    A. Flowlayout
  • 25. 

    Which of the following statements are true?

    • A.

      When you construct an instance of File, if you do not use the filenaming semantics of the local machine, the constructor will throw an IOException.

    • B.

      When you construct an instance of File, if the corresponding file does not exist on the local file system, one will be created.

    • C.

      When an instance of File is garbage collected, the corresponding file on the local file system is deleted.

    • D.

      None of the above

    Correct Answer(s)
    A. When you construct an instance of File, if you do not use the filenaming semantics of the local machine, the constructor will throw an IOException.
    B. When you construct an instance of File, if the corresponding file does not exist on the local file system, one will be created.
    C. When an instance of File is garbage collected, the corresponding file on the local file system is deleted.
  • 26. 

    You execute the code below in an empty directory. What is the result? File f1 = new File("dirname"); File f2 = new File(f1, "filename");

    • A.

      A new directory called dirname is created in the current working directory

    • B.

      A new directory called dirname is created in the current working directory. A new file called filename is created in directory dirname

    • C.

      A new directory called dirname and a new file called filename are created, both in the current working directory

    • D.

      A new file called filename is created in the current working directory

    • E.

      No directory is created, and no file is created

    Correct Answer
    E. No directory is created, and no file is created

Quiz Review Timeline +

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

  • Current Version
  • Mar 21, 2022
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 03, 2012
    Quiz Created by
    Pioneersuri
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.