Test Your Java 8

Test Your Java 8

Test Your Java 7 and Test Your Java 8 are advanced questions. Answers are given for each question at the end of each test. Answering these questions increases your knowledge in Java and helps you a lot when you appear for interviews. Solving these basic questions is your first step for Certification Exam preparation.

  1. The super() is used to have an explicit access to the methods and variables of superclass.
    a) True b) False
  2. .
    The above code
    a) prints Hello 1 b) prints Hello2 c) compiles, executes but no output d) raises a compilation error e) none
  3. We can stop a thread temporarily by calling stop( ) method on it.
    a) True b) False
  4. sleep(50);
    The above statement of a thread implies that the thread will get the processor-time
    a) any moment after 50 milliseconds. b) exactly after 50 milliseconds. c) even before 50 milliseconds if the processor is idle d) none
  5. When a read( ) method returns -1, it is to be understood that EOF is encountered. The same conclusion can be drawn with an EOFException also.
    a) True b) False
  6. What is the other immediate superclass of DataInputStream other than FilterInputStream ?
    a) InputStream b) DataInput c) Object d) FileInputStream e) none
  7. mkdir() is the command in Java to create a new directory.
    a) True b) False
  8. What is the return type of writeDouble( double d ), a method of RandomAccessFile.
    a) void b) int c) float d) double f ) boolean g) file object h) none
  9. The File method lastModified() returns
    a) date b) int c) double d) long e) specified by the programmer f) none
  10. javac –g HelloWorld.java
    The above compiler option is for
    a) grouping all the .class files while creating a package.
    b) encoding the international languages which Java supports.
    c) furnishing extra debugging information.
    d) none
  11. Color color1 = new Color(Color.red);
    The above statement produces same intensity of red color on any color monitor as Java is
    a) True b) False
  12. .
    What are the color values given by the drawString method of the above program ?
    a) 127, 127, 127 b) 0.5, 0.5, 0.5 c) depends on the underlying system d) does not compile as the program is error prone e) none
  13. Font size is measured in
    a) pixels b) points c) depends on the display structure of monitor
    e) depends on the resolution of monitor e) none
  14. g.drawRoundRect(50, 50, 100, 200, 100, 200);
    The above statement produces a
    a) rectangle b) rounded rectangle c) ellipse d) rounded square e) circle f) none
  15. The main purpose of Frame's dispose() method is
    Which one of the following statements is true ?
    a) to make the frame hide on the screen. b) to call back the frame whenever needed easily. c) to dispose the memory resources linked with the frame. d) to dispose the non-memory resources linked with the frame. e) none
  16. Java is platform-independent, that is a button created on a Windows-95 platform and a button created on a Unix or Macintosh platform look alike.
    a) True b) False
  17. .
    In the above program both label object and drawString method displays the same string After.
    Because they are displayed at the same cooridinates 50, 50 and as the string is the same, one overlaps the other so that only one After is displayed.
    a) True b) False
  18. .

    With click of Button1, Button2 will be added to the south of the Frame .
    a) True b) False
  19. getParameter( ) method of Applet returns
    a) only String b) String or any other data type and depends on the parameter passed from param tag c) none
  20. Which of the coding scheme(s) appletviewer supports.
    a) GIF b) JPEG c) a and b d) none
  21. Bytecode verification is not done in Applets.
    a) True b) False
  22. .

    The above code:
    a) compiles but raises an IllegalArgumentException b) does not compile as columns can not be 0 c) displays 12 buttons in 3 rows and 4 columns d) displays 12 buttons not in 3 rows and 4 columns e) none
  23. .
    The above program:
    a) does not compile as overridden method should have the same method signature b) object sb1 can’t be sent from subclass overridden method to super class method. c) displays the contents of PQR.java only. d) displays the contents of ABC.java and PQR.java. e) none
  24. .

    What code will print a list of all values in vector "v"?
    a) for(Enumeration e = v.elements(); e.hasMoreElements();)
    System.out.print(e.nextElement(i) + " ");

    b) while(v.hasMoreElements())
    System.out.print(v.nextElement() + " ");

    c) for(int i = 0; i < v.lastElement(); i++) System.out.print(v.elementAt(i).toString()); d) for(Enumeration e = v.elements(); e.hasMoreElements();) System.out.print(((Integer) e.nextElement()).intValue() + " "); e) for(int i = 0; i < v.capacity(); i++) System.out.print( v.elementAt( i ) ) ;

  25. Integer i = new Integer("5" ) ;
    System.out.println( Integer.parseInt(i.toString()) * i.intValue());

    The above code prints 25.
    a) True b) False

ANSWERS Test Your Java 8

1. b 2. d 3. b 4. a 5. a
6. b 7. a 8. a 9. d 10. c
11. b 12. a 13. b 14. c 15. d
16. b 17. b 18. b 19. a 20. c
21. b 22. c 23. d 24. b 25. a

Your Rating on Test Your Java 8

Correct Answers
1 to 5 : Poor
6 t0 10: Below average
11 t0 15: Average
16 to 20: Good
Above 20: Extraordinary

Pass your comments and suggestions on the improvement of this "Test Your Java 8".

Leave a Reply

Your email address will not be published. Required fields are marked *