• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

SCJP 1.4 Mock Exam – 6

  1. Please select signed integrals
    1. char, byte, and short
    2. byte, short, int, and long
    3. char, short, and long
  2. Java characters are …
    1. ASCII code
    2. Binary code
    3. Unicode
    4. ANSI code
  3. Please select the size of an int type
    1. 32 bytes
    2. 16 bits
    3. 32 bits
    4. 16 bytes
  4. Select default value of boolean type
    1. true
    2. false
    3. 0
    4. 1
  5. Consider the following line of code:

    char x[]=new char[10];

    After execution, what is value of x[0]?

    1. 0
    2. ‘\u0000’
    3. null
  6. A package statement MUST exist in all classes
    1. True
    2. False
  7. Please choose invalid identifiers
    1. temp
    2. BIGint
    3. 25_length
    4. !length

8.      Please select
floating point types

    1. byte
    2. int
    3. double
    4. short
    5. long
    6. float
  1. All operands are evaluated left to right
    1. true
    2. false
  2. Consider the following line of code:

    byte x=64;

    byte y=5;

    byte z= (byte)(x*y);

    After execution what is value of z?

    1. 320
    2. 0
    3. 645
    4. 64
  3. Consider the following line of code:

    int x=7;

    int y=4;

    int z=7/4;

    After execution what is value of z? 

    1. 1.75
    2. 0
    3. 1
    4. 2
  4. Please select the true statement for ! operator
    1. The ! operator inverts the value of a boolean expression
    2. The ! operator inverts the bit pattern of an integral expression.
    3. Both A and B
    4. None of the above
  5. Please select arithmetic operations which can result in
    AirthmeticException

    1. Multiplication: *
    2. Division: /
    3. Modulo: %
    4. Addition: +
    5. Subtraction: –
  6. Please select operators which perform bit shifts of the binary
    representation of the integral types

    1. <<
    2. >>
    3. >>>
    4. ~
    5. &
    6. ^
    7. |
  7. A protected method may be overridden by …
    1. A private method
    2. A protected method
    3. A public method
    4. All of the above
  8. A  public method may not be overridden by …
    1. A private method
    2. A protected method
    3. A public method
    4. All of the above
  9. The private modifier can be applied to …
    1. A variable
    2. A method
    3. A top level class
    4. All of the above
  10. The abstract modifier can NOT be applied to …
    1. A variable
    2. A method
    3. A class
    4. A constructor
  11. A class variable is declared using following modifiers
    1. protected
    2. private
    3. public
    4. static
  12. An unary operator operates on a single value
    1. True
    2. False
  13. The following types of loop are guaranteed to be executed at least
    once

    1. The do loop
    2. The while loop
    3. The for loop
    4. All of the above
  14. The switch() construct is used to make a choice based upon …
    1. A char value
    2. An int value
    3. A String value
    4. None of the above
  15. The circumstances that can prevent execution of the code in a
    finally block are

    1. The death of the thread
    2. The use of System.exit()
    3. It is always guaranteed to be executed.
  16. Select correct statement(s)
    1. The continue statement abandons the loop altogether
    2. The break statement causes the current iteration of the loop to be
      abandoned.
    3. The break statement abandons the loop altogether
  17. How can you declare a overloaded method?
    1. Reusing the method name with different arguments and same return
      type
    2. Reusing the method name with different arguments and different
      return type
    3. Reusing the name with identical arguments and return type
    4. None of the above
  18. How can you declare a overriding method?
    1. Using the same method name with identical arguments and return
      type
    2. Using the same method name with identical arguments and different
      return type
    3. Using the same method name with different arguments and same
      return type
    4. All of the above
  19. When a default constructor is provided by the compiler?
    1. If you define no constructor at all in a class
    2. When you define at least one constructor
    3. It is always provided whether you define a constructor or not
    4. It is never provided
  20. A static inner class can access …
    1. instance variables of the enclosing class
    2. static variables of the enclosing class
    3.  Both A and B
    4. None of the above
  21. An inner class created inside a method can access
    1. Any local variables of a method that contain an inner
      class.
    2. Any instance variables of the enclosing class
    3. Any final variables of the enclosing class or a method that
      contain an inner class.
    4. None of the above
  22. Please select true statement(s) for an anonymous inner
    class 

    1. An anonymous class can not extend to a superclass
    2. An anonymous class can not implement an interface
    3. An anonymous class can extend to a supperclass and implement an
      interface both.
    4. An anonymous class can extend to a supperclass or implement an
      interface
  23. Please select true statement(s) for a member inner class
    1. An inner class in class scope can have any accessibility of the
      top level class, including private.
    2. An Inner class defined local to a block may be static
    3. An anonymous inner class can not declare a constructor.
    4. An inner class can not have same name as enclosing class.
    5. All of the above
  24. Please select invalid statement(s) for a thread
    1. You can restart a dead thread
    2. You can’t call the methods of a dead thread
    3. Both of the above
    4. None of the above
  25. Select correct statements for a java.lang.String
    1. Strings are sequences of 16 bit Unicode characters.
    2. Strings are immutable.
    3. Both of the above
    4. None of the above
  26. Select correct statements for == operator.
    1. It compare object reference of two objects
    2. It compare the value of two objects
    3. Both of the above
    4. None of the above
  27. Please select collection(s) that do not reject duplicates
    1. java.util.List
    2. java.util.Set
    3. java.util.Map
    4. All of the above
  28. Please select a default layout manager of the java.awt.Panel
    1. java.awt.FlowLayout with left justified
    2. java.awt.FlowLayout with center justified
    3. java.awt.FlowLayout with right justified
    4. None of the above
  29. Please select a default layout manager for the java.awt.Frame
    1. java.awt.FlowLayout
    2. java.awt.BorderLayout
    3. java.awt.GridBagLayout
    4. None of the above
  30. Please select true statement for prefix operator(++x/–x).
    1. The prefix operator(++x/–x) evaluates the value of the operand
      after increment/decrement operation.
    2. The prefix operator(++x/–x) evaluates the value of the operand
      before increment/decrement operation.
    3. Both A and B
    4. None of the above
  31. Please select true statement(s) for shift operators.
    1. >>> operator always produces a positive number.
    2. >> always produces a positive number for a positive number.
    3. >> always produces a negative number for a negative number.
    4. None of the above
  32. Please select true statement(s) for shift operators.
    1. Shifting is not allowed in long integral type
    2. Shifting is not allowed in float integral type
    3. Shifting is not allowed in double integral type
    4. Shifting is not allowed in int integral type.
  33. Please identify correct assignment for boolean type.
    1. boolean javaExam=true;
    2. boolean javaExam=True;
    3. boolean javaExam=1;
    4. All of the above
  34. Bitwise operator can be applied to …
    1. Integral types
    2. Float types
    3. Both of the above
    4. None of the above
  35. instanceof operator can be used with …
    1. interfaces
    2. Arrays
    3. Classes
    4. All of the above
  36. Please select true statement(s)
    1. The equals method compares content of two objects
    2. The == operator tests reference of two objects
    3. The equals method compares reference of two objects.
    4. The == operator compares content of two objects
  37. Please identify invalid use of comparison operator for the
    following code:

    String s=new String(“S”);

    String t=new String(“T”);

    int x=83;

    int y=84;

    1. s == t
    2. x!=y
    3. x==s
    4. s!=t
  38. Please select true statement(s) for instanceof operator:
    1. The instanceof operator can be applied to object reference
    2. The instanceof operator can be applied to an array.
    3. Both of the above
    4. None of the above
  39. please select true statement(s) for static modifier.
    1. A static method can access non-static variables of the class.
    2. A static method can call non-static methods.
    3. A static method can be overridden by non-static method.
    4. None of the above
  40. Please, select true statement(s) for thread.
    1. Invoking a constructor of a Thread registers the thread with
      thread scheduler.
    2. Calling a start() method of thread registers the thread with
      thread scheduler.
    3. Calling a run() method of thread registers the thread with thread
      scheduler.
    4. All of the above.
  41. Invoking yield() on a running thread cause following effect(s):
    1. A running thread will be placed in suspended state.
    2. A running thread will be placed in sleeping state.
    3. A running thread will be placed in ready state.
    4. Neither of the above.
  42. The default priority of the thread is
    1. 0
    2. 1
    3. 5
    4. 10
  43. Which of the following methods are NOT static of Thread class?
    1. start()
    2. sleep(long l)
    3. run()
    4. yield()
  44. Select true statement(s) about an inner class declared inside a
    method, also known as local inner class

    1. The local inner class can access any local variables declared in
      the method and the parameters passed to the method.
    2. The local inner class can access only public variables declared in
      enclosing class
    3. The local inner class can access public, private, and protected
      variables declared in enclosing class.
    4. The local inner class can access only final declared variables in
      the method.
  45. How can you prevent class JavaExam from being extended?

A.     declare class static
JavaExam

B.     declare class
synchronized JavaExam

C.     declare class final
JavaExam

D.     None of the above

  1. Assume that following methods are declared in one class.

    1.  public void addElement(Object javaExam)

    2.  public void addElement( Object [] javaExam)

    3.  public Object addElement ( int index, Object javaExam)

    Please select true statement(s) for above methods.

 .
All methods are example of overloading method

A.     All methods are example
of overriding method

B.     Method # 1 and method #
2 are example of overloading method, whereas method # 3 is an example of
overriding method.

C.     None of the above

  1. When can’t you override a method?

 .
when method is declared abstract

A.     When method is declared
final

B.     when method is declared
private

C.     when method is declared
static

  1. Please select invalid declaration of the top level class

 .
public abstract final class JavaExam

A.     public final class
JavaExam implement  Runnable

B.     protected static class
JavaExam

C.     public class JavaExam
extend Thread

  1. Please select invalid types for a switch construct

 .
float

A.     long

B.     String

C.     All of the above

  1. Please select invalid java keywords

 .
include

A.     ifdef

B.     sizeof

C.     goto

  1. Which of the following statements are NOT true about Java garbage
    collection Thread?

 .
The garbage collection thread has a low priority

A.     The garbage collection
thread can be invoked at any time

B.     A call to System.gc()
is guaranteed to invoke garbage collection thread immediately

C.     A call to
Runtime.getRuntime().gc()  is guaranteed to invoke garbage
collection thread immediately

  1. An inner class can not declare______ variables.

 .
static

A.     protected

B.     final

C.     transient

  1. Which of the following types can be added to java.util.Vector?

 .
reference

A.     null

B.     int

C.     All of the above

  1. Please select a true statement about delete() method of
    java.io.File.

 .
It can delete a file

A.     It can delete an empty
directory

B.     Both of the above

C.     Neither of the above

  1. The continue statement causes the current iteration
    of the loop to be skipped and the next iteration starts.

 .
True

A.     False

  1. The return type of constructor is void.

 .
True

A.     False

  1. ‘null’ is valid java type.

 .
True

A.     False

  1. Invoking a constructor of java.io.File class creates a file on the
    file system.

 .
True

A.     False

  1. Select true statement(s) about native modifier.

 .
native modifier can be applied to a class

A.     native modifier can be
applied to a method

B.     native modifier can be
applied to an instance variable

C.     native variable can be
applied to a class variable

  1. What method(s) needed to be declared  by a  class
    implementing Runnable interface?

 .
public void start()

A.     public void run()

B.     public boolean start()

C.     public boolean run()

  1. The priority of a newly created thread is always
    Thread.NORM_PRIORITY.

 .
True

A.     False

  1. What methods are declared in java.lang.Thread
    class?

 .
public static void sleep(long millis, int nanos)

A.     public static native
void sleep(long millis, int nanos)

B.     public static native
void sleep(long millis)

C.     public static void
sleep(long millis)

  1. A yield method of the Thread class suspends the
    operation of the current thread.

 .
True

A.     False

  1. What methods are NOT synchronized in java.util.Vector class?

 .
size()

A.     add(int index, Object
element)

B.     capacity()

C.     get(int index)

  1. Please select unchecked exception(s)?

 .
java.lang.NullPointerException

A.
java.lang.ClassNotFoundException

B.
java.lang.ClassCastException

C.     java.awt.AWTException

  1. Which of the following declarations are valid to throw an
    exception?

 .
throw new java.lang.Exception();

A.     throws new
java.lang.Exception();

B.     Both of the above

C.     None of the above

  1. Which of the following classes are immutable?

 .
java.lang.String

A.     java.lang.StringBuffer

B.     java.util.Vector

C.     java.lang.Integer

  1. Which of the following classes store and retrieve values based on a
    key?

 .
java.util.Hashtable

A.     java.util.Vector

B.     java.util.LinkedList

C.     java.util.HashMap

  1. Which of the following classes can store null value for a key?

 .
java.util.Hashtable

A.     java.util.HashMap

B.     java.util.Properties

C.     All of the above

  1. java.util.Vector uses synchronized methods to store and retrieve
    values.

 .
True

A.     False

  1. java.util.Hashtable uses synchronized methods to store and retrieve
    values.

 .
True

A.     False

  1. java.util.HashMap uses synchronized methods to store and retrieve
    values.

 .
True

A.     False

  1. Which of the following collections maintain object references in
    the order they were added?

 .
java.util.Vector

A.     java.util.Hashtable

B.     java.util.HashMap

C.     java.util.ArrayList

  1. java.util.hashtable implements which of the following
    interfaces?

 .
java.util.Dictionary

A.     java.util.Map

B.     java.util.HashMap

C.     java.util.Hashmap

Answers:

  1. B
  2. C
  3. C
  4. B
  5. B
  6. B
  7. C and D
  8. C and F
  9. A
  10. D.  Comment:  A byte value can represent a range of
    -128 to +127.  Arithmetically answer is 320, but when you store
    this result to a byte variable you will get a value 64 since result is
    out of the range (-128 to +127).
  11. C
  12. A
  13. B and C are correct
  14. A, B, and C
  15. B and C
  16. A and B
  17. A and B
  18. A and D
  19. D
  20. A. Comment:  + and – operator can take two values
  21. A
  22. A and B
  23. A and B
  24. C
  25. A and B
  26. A
  27. A
  28. B
  29. C
  30. D
  31. A , C, and D
  32. C.  Thanks Chris Pereira for your feedback in our discussion
    area.
  33. C
  34. A
  35. A
  36. B
  37. B
  38. A
  39. B, and C.
  40. B and C
  41. A
  42. A
  43. D
  44. A and B
  45. C
  46. C
  47. D
  48. B
  49. C
  50. C
  51. A and C
  52. C and D
  53. C
  54. A
  55. B
  56. A, B, C, and D
  57. D
  58. A, B, and C
  59. B, C, and D
  60. A
  61. A and B
  62. C
  63. A
  64. B
  65. A
  66. B
  67. B
  68. B
  69. B  Comment:  A newly created thread inherits the
    priority of the Thread that creates it.
  70. A and C
  71. A
  72. A, B, and C
  73. A and C
  74. A
  75. A and D
  76. A and D
  77. B
  78. A
  79. A
  80. B
  81. A and D
  82. B

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact