Java Interview Questions

Java Interview Questions

Latest Java Interview Questions

  1. Which class cannot be sub classed (or extended) in java?

(a) abstract class

(b) parent class

(c) Final class

(d) None of above

  1. Can we declare abstract static method

(a) Yes

(b) No

  1. Can we access private class outside the package


(b) No

  1. Why we use array as a parameter of main method

(a) it is syntax

(b) Can store multiple values

(c) Both of above

(d) None of above

  1. Suspend thread can be revived by using

(a) start() method

(b) suspend() method

(c) resume() method

(d) yield() method

  1. Runnable is

(a) Class

(b) Method

(c) Variable

(d) Interface

  1. Which collection class associates values with keys, and orders the keys according to their natural order

(a) java.util.HashSet

(b) java.util.LinkedList

(c) java.util.TreeMap

(d) java.util.SortedSet

  1. Which method is used to perform DML statements in JDBC

(a) execute()

(b) executeUpdate()

(d) executeQuery()

(d) None of above

  1. Which of the following below are valid isolation levels in J2EE



(c) Only A

(d) Both A and B

  1. Session beans are created by the client submitting the query to the database

(a) True

(b) False

  1. Which methods are utilized to control the access to an object in multi threaded programming

(a) Asynchronized methods

(b) Synchronized methods

(c) Serialized methods

(d) None of above

  1. In Runnable, many threads share the same object instance

(a) True

(b) False

  1. Java beans have no types

(a) True

(b) False

  1. Program which executes applet is known as

(a) applet engine

(b) virtual machine

(c) JVM

(d) None of above

  1. Which statement is static and synchronized in JDBC API

(a) executeQuery()

(b) executeUpdate()

(c) getConnection()

(d) prepareCall()

  1. The JDBC-ODBC bridge is

(a) Multithreaded

(b) Singlethreaded

(c) Both of above

(d) None of above

  1. All raw data types should be read and uploaded to the database as an array of

(a) int

(b) char

(c) boolean

(d) byte

  1. The class java.sql.Timestamp is associated with

(a) java.util.Time

(b) java.sql.Time

(c) java.util.Date

(d) None of above

  1. Which of the following statements about arrays is syntactically wrong

(a) arrayName[] p = new arrayName[5];

(b) arrayName p[5];

(c) arrayName[] p [];

(d) arrayName p[][] = new arrayName[2][];

  1. The Externalizable interface extends the serializable interface

(a) True

(b) False

  1. Converting a primitive type data into its corresponding wrapper class object instance

is called

(a) boxing

(b) wrapping

(c) instantiation

(d) auto boxing

  1. Package of drawstring() method is

(a) java.applet


(c) javax.swing

(d) java.awt

  1. Which method executes only once

(a) start() method

(b) init() method

(c) stop() method

(d) destroy() method

  1. Object which can store group of other objects is called

(a) Collection object

(b) Java object

(c) Package

(d) Wrapper

  1. All collection classes are available in

(a) package

(b) java.lang package

(c) java.awt package

(d) java.util package

  1. Thread class is available in

(a) package

(b) java.lang package

(c) java.awt package

(d) java.util package

  1. Minimum threads in a program are

(a) 1

(b) 2

(c) 5

(d) Many

  1. JIT meaning

(a) java in time

(b) just in time

(c) join in time

(d) none of above

  1. After the compilation of the java source code, which file is created by the JVM

(a) .class

(b) .java

(c) .cdr

(d) .doc

  1. pow () is associated with which class

(a) Math class

(b) Input stream class

(c) Object class

(d) None of above

31) What will be the value of x after the following code segment is executed?

int x = 3;

x = x + x;

x = x + x;

(a)                          3

(b)                          6

(c)                          9

(d)                          12

(e)                          none of the above

32) What will be the value of y after the following code segment is executed?

int x = 3,  y = 5;

x = y;

y = x;

(a)                          3

(b)                          5

(c)                          6

(d)                          10

(e)                          none of the above

33) Suppose we have an array declared by

int [] intArr = {2,4,6,8,10};

What value is stored in intArr[1] ?

(a)                          1

(b)                          2

(c)                          4

(d)                          0

(e)                          none of the above

34) What will be output by the following code segment?

int sum = 0;

int count = 1;

while (count < 5)

{   sum = sum + count;

count = count + 2;



(a)                          10

(b)                          15

(c)                          4

(d)                          9

(e)                          none of the above


35) What will be output by the following code segment?

for (int row = 1; row <= 3; row ++)


for (int count = 1; count <= (4 – row); count ++) {





(a)                          *



(b)                        ***



(c)                          ***



(d)                          *



(e)                          none of the above

36) After the following code fragment, what is the value in a?

String s;

int a;

s = “Foolish boy.”;

a = s.indexOf(“fool”);

  • -1
  • 0
  • 4
  • random value

37) If s=”text”, what is the value returned by s.length()?

(a)        false

(b)        true

(c)        4

(d)        5

38) The sequence \n does what?

(a)        Makes a link
(b)        Prints a backslash followed by a n

(c)        Adds 5 spaces
(d)      Starts a new line

39) What does the following line of code mean?

(a)         table is a variable to refers to a real number

(b)        table is a variable that refers to two numbers

(c)        It is not legal Java code

(d)      table is a variable that refers to an array

40) If result=2+3*5, what is the value of result?

(a)        25

(b)        14

(c)        10

(d)        17

2 Comments on this Post

  1. Uh6dbOwkEGL7z

    Hi there! Nice stuff, please do tell me when you finally post something like this!

  1. By URL on June 11, 2017 at 3:16 AM

    … [Trackback]

    […] Read More: […]

Leave a Comment