100% found this document useful (2 votes)
9K views34 pages

200 Real Time Java Multiple Choice Questions and Answers - Mcqs

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (2 votes)
9K views34 pages

200 Real Time Java Multiple Choice Questions and Answers - Mcqs

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 34

200 REAL TIME JAVA Multiple Choice

Questions and Answers | MCQs


JAVA Multiple Choice Questions and Answers pdf free download for fresher’s experienced interview
questions objective type tutorials certification faqs

All the correct answer were highlighted with Yellow


1. Java programs are

A) Faster than others

B) Platform independent

C) Not reusable

D) Not scalable

2. Java has its origin in

A) C programming language

B) PERRL

C) COBOL

D) Oak programming language

3. Which one of the following is true for Java.

A) Java is object oriented and interpreted

B) Java is efficient and faster than C

C) Java is the choice of everyone.

D) Java is not robust.

4. The command javac is used to

A) debug a java program

B) compile a java program

C) Interpret a java program

D) Execute a java program

5. Java servlets are an efficient and powerful solution for creating ………….. For the web.
A) Dynamic content

B) Static content

C) Hardware

D) Both a and b

6. Filters were officially introduced in the Servlet ……………… specification.

A) 2.1

B) 2.3

C) 2.2

D) 2.4

7. Which is the root class of all AWT events

A) java.awt.ActionEvent

B) java.awt.AWTEvent

C) java.awt.event.AWTEvent

D) java.awt.event.Event

8. OOP features are

i) Increasing productivity (ii) Reusability (iii) Decreasing maintenance cost (iv) High
vulnerability

A) 1,2 & 4

B) 1,2 & 3

C) 1, 2 & 4

D) None of the above

9. Break statement is used to

i) get out of method (ii) end a program (iii) get out of a loop (iv) get out of the system

A) 1 & 2

B) 1,2 & 3

C) 1 & 3
D) 3

10. Native – protocol pure Java converts ……….. into the ………… used by DBMSs
directly.

A) JDBC calls, network protocol

B) ODBC class, network protocol

C) ODBC class, user call

D) JDBC calls, user call

1. The JDBC-ODBC bridge allows ……….. to be used as ………..

A) JDBC drivers, ODBC drivers

B) Drivers, Application

C) ODBC drivers, JDBC drivers

D) Application, drivers

2. Which of the following is true about Java.

A) Java does not support overloading.

B) Java has replaced the destructor function of C++

C) There are no header files in Java.

D) All of the above.

3. ……………. are not machine instructions and therefore, Java interpreter generates
machine code that can be directly executed by the machine that is running the Java program.

A) Compiled Instructions

B) Compiled code

C) byte code

D) Java mid code

4. The command javac

A) Converts a java program into binary code

B) Converts a java program into bytecode


C) Converts a java program into machine language

D) None of the above.

5. Which of the following is not the java primitive type

A) Byte

B) Float

C) Character
D) Long double

6. Command to execute compiled java program is

A) java

B) javac

C) run

D) javaw

7. Java Servlet

i) is key component of server side java development (ii) is a small pluggable extension to a
server that enhances functionality (iii) runs only in Windows Operating System iv) allows
developers to customize any java enabled server

A) i, ii & iii are ture

B) i, iii & iv are true

C) ii, iii & iv are true

D) i, ii & iv are true

8. Inner classes are

A) anonymous classes

B) nested classes

C) sub classes

D) derived classes

9. How many times does the following code segment execute int x=1, y=10, z=1; do{y–;
x++; y-=2; y=z; z++} while (y>1 && z<10);
A) 1

B) 10

C) 5

D) infinite

10. State weather the following statement is true or false for EJB.

1. EJB exists in the middle-tier

2. EJB specifies an execution environment

3. EJB supports transaction processing

A) 1-true, 2. true, 3. true

B) 1- true, 2. false, 3. true

C) 1- false, 2- false, 3- false

D) 1-true, 2-true, 3-false3- false D) 1-true, 2-true, 3-false

1. All java classes are derived from

A) java.lang.Class

B) java.util.Name

C) java.lang.Object

D) java.awt.Window

2. The jdb is used to

A) Create a jar archive

B) Debug a java program

C) Create C header file

D) Generate java documentation

3. What would happen if “String[]args” is not included as argument in the main method.

A) No error

B) Compilation error
C) Program won’t run

D) Program exit

4. For execution of DELETE SQL query in JDBC, …………. method must be used.

A) executeQuery()

B) executeDeleteQuery()

C) executeUpdate()

D) executeDelete()

5. Which method will a web browser call on a new applet?

A) main method

B) destroy method

C) execute method

D) init method

6. Which of the following is not mandatory in variable declaration?

A) a semicolon

B) an identifier

C) an assignment

D) a data type

7. When a program class implements an interface, it must provide behavior for

A) two methods defined in that interface

B) any methods in a class

C) only certain methods in that interface

D) all methods defined in that interface

8. In order to run JSP ……………….. is required.

A) Mail Server

B) Applet viewer

C) Java Web Server


D) Database connection

9. State true of false.

i) AWT is an extended version of swing

ii) Paint( ) of Applet class cannot be overridden

A) i-false, ii-false

B) i-false,ii-true

C) i-true, ii-false

D) i-true, ii-true

10. Prepared Statement object in JDBC used to execute……….. queries.

A) Executable

B) Simple

C) High level

D) Parameterized

1. In Java variables, if first increment of the variable takes place and then the assignment
occurs. This operation is also called ……………………….. .

A) pre increment

B) post increment

C) incrementation

D) pre incrementation

2. When the operators are having the same priority, they are evaluated
from……………..…………. in the order they appear in the expression.

A) right to left

B) left to right

C) any of the order

D) depends on compiler
3. In java , …………. can only test for equality, whereas ………… can evaluate any type of
the Boolean expression.

A) switch, if

B) if, switch

C) if, break

D) continue, if

4. The ………………….. Looks only for a match between the value of the expression and
one of its case constants.

A) if

B) match

C) switch

D) None of the above

5. System.in.read() is being used, the program must specify the ……………… clause.

A) throws.java.out.IOException

B) throws.java.in.IOException

C) throws.java.io.IOException

D) throws.java.io.InException

6. By using ………………. you can force immediate termination of a loop, by passing the
conditional expression and any remaining code in the body of the loop.

A) Break

B) Continue

C) Terminate

D) Loop Close

7. The out object is an object encapsulated inside the …………….. class, and represents the
standard output device.

A) standard

B) local
C) globlal

D) system

8. The third type of comment is used by a tool called ……………… for automatic
generation of documentation.

A) Java commenting

B) Java generator

C) Java doc

D) Java loc

9. In the second type the information written in java after // is ignored by the

…………………..

A) Interpreter

B) Compiler

C) Programmer

D) All of the above

10. The compiled java program can run on any ………………… plateform having Java
Virtual Machine (JVM) installed on it.

A) program

B) java

C) hardware

D) non java

1. Prepared statement Object in JDBC is used to execute ……………………… queries.

A) executable

B) simple

C) high level

D) parameterized

2. In JDBC …………………… imports all Java classes concerned with database


connectivity.

A) javax.sql.*

B) java.mysql.*

C) java.sql.*

D) com.*

3. MS-SQL stores data in a …………………… file format.

A) .DAT

B) .MDB

C) .MSSQL

D) .OBJ

4. Ingres is a ……………………

A) Socket

B) Compiler

C) Database

D) Web server

5. In Java servlet method init( ) is called ………………… times.

A) 1

B) 2

C) 0

D) multiple

6. State true or false for Java Program.

i) All class variables are instance variables

ii) All protected methods are friendly methods

A) i-false, ii-false

B) i-false, ii-true

C) i-true, ii-false
D) i-true, ii-true

7. State true or false for Java Program.

i) Data members of an interface are by default final

ii) An abstract class has implementations of all methods defined inside it.

A) i-false, ii-false

B) i-false, ii-true

C) i-true, ii-false

D) i-true, ii-true

8. …………………… of a remotely accessible object must implement …………….

A) all methods, RemoteException

B) class, RemoteException

C) class, RemoteInterface

D) all methods, RemoteInterface

9. ………………….is the key to ……………………

A) Serialization, persistence

B) Persistence, inheritance

C) Inheritance, object

D) Persistence, serialization

10. A method name myMethod( ) that needs two integer arguments is declared as

A) public void myMethod( );

B) public void myMethod(int a, int b);

C) public void myMethod(int a, b);

D) public int myMethod(a, b);

1. JSP embeds in ……………. in ………………….

A) Servlet, HTML
B) HTML, Java

C) HTML, Servlet

D) Java, HTML

2. The class at the top of exception class hierarchy is ……………………..

A) ArithmeticException

B) Throwable

C) Class

D) Exception

3. In a java program, package declaration ……………….. import statements.

A) must precede

B) must succeed

C) may precede or succeed

D) none

4. The class string belongs to ………………. package.

A) java.awt

B) java.lang

C) java.applet

D) java.string

5. …………… package is used by compiler itself. So it does not need to be imported for use.

A) java.math

B) java.awt

C) java.applet

D) java.lang

6. State true or false for the following statements in Java.

i) Java beans slow down software development process.

ii) Java Servlets do not have built in multithreading feature.


A) i-false, ii-false

B) i-false, ii-true

C) i-true, ii-false

D) i-true, ii-true

7. State whether true or false.

i) init( ) of servlet is called after a client request comes in

ii) Servlets are ultimately converted into JSP

A) i-false, ii-false

B) i-false, ii-true

C) i-true, ii-false

D) i-true, ii-true

8. What will be the result of compiling following code.

public class MyClass{

public static void main(String args[]){

System.out.println(“In first main()”);

public static void main(char args[]){

System.out.println(„a‟);

A) Code will not compile and will give “Duplicate main () method declaration” error

B) Code will compile correctly but will give a runtime exception

C) Code will compile correctly and will print “In first main()” (without quotes) when it
is run

D) Code will compile correctly and will print “a” (without quotes) when it is run

9.Match the following.


a) Java 1) is a tool for debugging java program

b) Javah 2) is a tool for creating C-like header files

c) Javap 3) runs java bytecode

d) jdb 4) prints java code representation

A) a-3, b-2,c-1

B) a-3, b-2, c-4, d-1

C) a-1, b-2, c-3, d-4

D) a-2, b-1, c-3, d-4

10.State true or false.

i) init() is called after start() in applet

ii) applets are used for networking

iii) inheritance is a part of Java Foundation Classes

iv) final does not prevent inheritance

A) i-true, ii-true, iii-false, iv-true

B) i-false, ii-false, iii-false, iv-false

C) i-true, ii-true, iii-true, iv-true

D) i-true, ii-false, iii-false, iv-false

1. The ……………… and ……………….. classes are abstract classes that support reading
and writing of byte streams.

A) reader, writer

B) inputstream, outputstream

C) objectinputstream, objectoutputstream

D) none

2. What is the error in the following code?

class Test
{

abstract void display( );

A) No error

B) Method display ( ) should be declared as static

C) Test class should be declared as abstract

D) Test class should be declared as public

3. A package is a collection of

A) classes

B) interfaces

C) editing tools

D) classes and interfaces

4. Which of the following methods belong to the string class?

A) length( )

B) compare To ( )

C) equals ( )

D) All of them

5. What will be the output of the following code?

byte x=64, y;

y= (byte) (x<<2);

System.out.println(y);

A) 0

B) 1

C) 2

D) 64
6. If m and n are int type variables, what will be the result of the expression m%n when m=5
and n=2 ?

A) 0

B) 1

C) 2

D) None of the above

7. Which of the following control expressions are valid for an if statement?

A) An integer expression

B) A Boolean expression

C) Either A or B

D) Neither A nor B

8. The concept of multiple inheritance is implemented in Java by

A) extending two or more classes

B) extending one class and implementing one or more interfaces

C) implementing two or more interfaces

D) both B and C

9. Which of the following do not represent legal flow control statements?

A) break;

B) return;

C) exit();

D) continue outer;

10. Data input is

A) an abstract class defined in java.io

B) a class we can use to read primitive data types

C) an interface that defines methods to open files.

D) an interface that defines methods to read primitive data types.


1. Using which keyword we can access value of the instance variables and class variables of
that class inside the method of that class itself.

A) super

B) final

C) this

D) either super or this

2. If a variable is declared final, it must include …………………. value.

A) integer

B) no

C) initial

D) float

3. State true or false.

i) Jpanel is a class included in awt package.

ii) Anonymous classes are mostly used for event handling. iii) Names of anonymous classes
must be unique

iv) JOptionPane is an inner class

A) i-false, ii-false, iii-true, iv-true

B) i-true, ii-false, iii-true, iv-false

C) i-false, ii-true, iii-false, iv-false

D) i-true, ii-false, iii-false, iv-true

4. In java, string is a ………….

A) primitive data type

B) abstract data type

C) combination of boolean

D) None of the above

5. Methods can be overloaded with a difference only in the type of the return value ..

A) Not supported
B) False

C) True

D) None of the above

6. Each method in a java class must have a unique name .

A) Not necessary

B) True

C) False

D) None of the above

7. State true or false.

i) comparisons precede logical operations in java

ii) assignment operations succeed increment operations

iii) arithmetic operations succeed comparisons

iv) x precede +

A) i-true, ii-true, iii-false, iv-true

B) i-true, ii-false, iii-true, iv-false

C) i-false, ii-true, iii-false, iv-false

D) i-true, ii-false, iii-false, iv-true

8. It is important feature of java that it always provides a default constructor to a class.

A) Not supported

B) False

C) True

D) None of the above

9. ………………….. is the key to ………………

A) Serialization, persistence

B) Persistence, inheritance

C) Inheritance, object
D) Persistence, serialization

10. State true of false.

i) Public can only be assigned to class

ii) Protected protects a statement

iii) Protected method is never accessible outside the package

iv) Friendly variable may be accessible outside class

A) i-true, ii-true, iii-false, iv-true

B) i-true, ii-false, iii-true, iv-false

C) i-false, ii-true, iii-false, iv-false

D) i-true, ii-false, iii-false, iv-true

1. In java a ………………….. is a sequence of characters. Java Objective Questions with


Answers Schema of the general architecture of a program running in a Java Virtual Machine
(Photo credit: Wikipedia)

A) string

B) arrayChar

C) groupChar

D) collection

2. Java programs perform I/O through ………..

A) I/O methods

B) I/O package

C) streams

D) compiler

3. What is byte code in the context of Java?

A) The type of code generated by a Java compiler

B) The type of code generated by a Java Virtual Machine

C) It is another name for Java source file


D) It is the code written within the instance methods of a class

4. Which of the following statements about abstract methods/classes in Java is true?

A) An abstract class cannot be instantiated.

B) Constructors can be abstract.

C) A subclass of an abstract class must defined the abstract methods.

D) Static methods may be declared abstract.

5. Which of the following statement is false?

A) The sleep () method should be enclosed in try ……… catch block

B) The yield() method should be enclosed in try ……… catch block.

C) A thread can be temporarily suspended from running by using the wait() method.

D) A suspended thread using suspend () method can be revived using the resume() method.

6. The new operator dynamically allocates …………..for an object and returns a reference to
it.

A) classes

B) variables

C) memory

D) none of the above

7. Which of the following statements correctly describes an interface?

A) It‟s a concrete class

B) It‟s a super class

C) It’s a type of abstract class

D) It‟s a subclass

8. What is the priority of the Garbage collector thread of jdk?

A) Low Priority

B) Highest Priority

C) Medium Priority
D) Decided at run time

9. ……………. is a feature that allows one interface to be used for a general class of actions.

A) Class

B) Inheritance

C) Polymorphism

D) Interface

10. The default package that is implicitly called in a java program is ………….

A) java.Lang

B) java.System

C) java.Window

D) java.Lang.System

1. Java was developed by the company

A) Sun Micro systems Image representing Sun Microsystems as depicte… Sun Micro
systems Image CrunchBase

B) Microsoft

C) Micro tech

D) IBM

2. What is the file extension of compiled java program?

A) .class

B) .java

C) .css

D) .html

3. ……………… keyword is used to invoke the current object.

A) New

B) That
C) This

D) Me

4. Which of the function is used to convert string to Number in java program?

A) to Number()

B) conString()

C) valueOf()

D) toString()

5. What are the part in executing a Java program and their purposes?

A) Java Compiler

B) Java Interpreter

C) Java Pre-processor

D) Directive Pre-processor

6. Method overloading is one of the way that Java supports …………

A) encapsulation

B) class

C) inheritence

D) polymorphism

7. Java support RMI. What does this RMI stands for?

A) Random Memory Interface

B) Remote Method Invocation

C) Random Method Invocation

D) Remote Memory Interface

8. Which of the following represent legal flow control statements?

A) break;

B) break();

C) continue(inner);
D) exit();

9. The keywords reserved but used in the initial version of Java are

A) union

B) const

C) inner

D) goto

10. What is the default return type of main() ..

A) void

B) double

C) float

D) int

1. If m and n are int type variables, what will be the result of the expression m%n when m=-
14 and n=-3?

A) 4

B) 2

C) -2

D) -4

2. Consider the following code

if(number>=0)

if(number>0)

system.out.println(“Number is positive”);

else

system.out.println(“Number is negative”);

What will be the output if number is equal to 0?

A) Number is negative
B) Number is positive

C) Both A and B

D) None of the above

3. Consider the following code:

char c=‟a‟;

switch (c)

{ case „a‟;

system.out.println(“A”);

case „b‟;

system.out.println(“B”);

default; system.out.println(“C”); }

For this code, which of the following statement is true?

A) Output will be A

B) Output will be A followed by B

C) Output will be A, followed by B, and then followed by C

D) Code is illegal and therefore will not compile 4. Consider the following class
definition.class Student extends String

{}

What happens when we try to compile this class? A) Will not compile because class body is
not defined

B) Will not compile because the class in not declared public.

C) Will not compile because string is abstract.

D) Will not compile because string is final.

5. What is wrong in the following class definitions?

abstract class print

{ abstract show(); } class Display extends Print { }

A) Nothing is wrong
B) Wrong. Method show () should have a return type

C) Wrong. Method show () is not implemented in Display

D) Wrong. Display does not contain any numbers.

6. What is the error in the following class definitions?

abstract class XY { abstract sum(int x, int y){ }}

A) Class header is not defined properly

B) Constructor is not defined

C) Method is not defined properly

D) No error.

7. Which of the following statements are true?

i) We cannot use abstract classes to instantiate objects directly.

ii) The abstract methods of an abstract class must be defined in its subclass.

iii) We cannot declare abstract constructors. iv) We may declare abstract static methods.

A) Line i only

B) Line ii only

C) Line i and ii only

D) Line i, ii and iii only

8. We would like to make a member of a class visible in all subclasses regardless of what
package they are in. Which one of the following keywords would archive this?

A) Private

B) Protected

C) Public

D) Private Protected

9. The use of protected keyword to a member in a class will restrict its visibility as follows:

A) Visible only in the class and its subclass in the same package.

B) Visible only inside the same package.


C) Visible in all classes in the same package and subclasses in other packages

D) Visible only in the class where it is declared.

10. Consider the following code: interface

Area {float compute (float x, float y) ; }

Class Room implements Area {float compute (float x, float y)

{return (x&y);

What is wrong with the code?

A) Interface definition is incomplete

B) Method compute () in interface Area should be declared public

C) Method compute () in class Room should be declared public

D) All the above

1) Which of the following statement is/are true?

i) The name of a java program file must match the name of the class with the extension .java
ii) Two methods cannot have the same name in java

A. i- only

B. ii- only

C. Both i and ii

D. None of the above

2) Which of the following represent (s) of a hexadecimal number?

A. 570

B. (hex)5

C. 0X9F

D. 0X5
3) …….. can appear only where in the body of a java method.

A. definition

B. declaration

C. determine

D. package

4) State whether the following statement are True or False?

i) The modulus operator (%) can be used only with integer operands

ii) Declarations can appear anywhere in the body of a java method

A. i-True, ii-False

B. i-False, ii-True

C. i-True, ii-True

D. i-False, ii-False

5) Which of the following will produce a value of 22 if x=22.9?

A. ceil(x)

B. round(x)

C. rint(x)

D. abs(x) 6) …….. is passed to a method by use of call by reference.

A. Variables

B. Objects

C. Methods

D. Operators

7) Using the keyboard interface you can fully abstract a …

A. Method

B. Keyword

C. Class

D. Variables
8) State True or False for the following statements in java. i) All the bitwise operators have
same level of precedence in java ii) The default can is always required in the switch selection
structure.

A. i-True, ii-False

B. i-False, ii-True

C. i-True, ii-True

D. i-False, ii-False

9) Java is designed for ………. environment of the Internet.

A. Development

B. Deduction

C. Distributed

D. Web Design

10) Which of the following will produce a value of 10 if x=9.7?

A. floor(x)

B. abs(x)

C. rint(x)

D. round(x)

11) Variable declared as ……… do not occupy on a per instance basis.

A. Static

B. Final

C. Abstract

D. Code

12) Which of the following is not keyword?

A. NULL

B. implements

C. protected

D. switch
13) The …… statement is used to terminate a statement sequence.

A. Break

B. Switch

C. Continue

D. Wait

14) Multidimensional arrays are actually ……

A. Arrays of element

B. Arrays of variable

C. Arrays of arrays

D. Arrays of variable

15) Which of the following keywords are used to control access to a class member?

i) default ii) abstract iii) protected iv) interface v) public

A. i, ii and iii only

B. ii, iii and iv only

C. iii, iv and v only

D. ii, iii and v only

16) ……. is used for initialize the value to the string object.

A. Character literals

B. String literals

C. String group literals

D. Group literals

17) Which of the following methods can be used to remove a component from the display?

A. delete()

B. remove()

C. disappear()
D. hide()

18) Which of the following statements are valid array declaration? i) int number(); ii) float
average[ ]; iii) double[]marks; iv) counter int[];

A. i and ii

B. ii and iii

C. iii and iv

D. All i, ii, iii and iv

19) Which of the following methods belong to the String class?

A. length()

B. CompareTo()

C. equals()

D. substring()

E. All of the above

20) Which of the following in NOT represent legal flow control statements?

A. break;

B. break();

C. continues outer;

D. return;

1) Object is an …….. of class.

A. instance

B. implements

C. inheritance

D. invoke

2) ……. is the wrapper class.

A. Random
B. Byte

C. Vector

D. String

3) Class is a …….. entity.

A. logical

B. Physical

C. up normal

D. collection of

4) Which of the following denotes a javadoc comment?

A. //#

B. /*

C. /**

D. //**

5) Object is a …….. entity. A. normal

B. physical

C. logical

D. normal

6) One interface can inherit another by use of the keyword ……..

A. public

B. extends

C. method name

D. class name

7) ……… must be the first non comment statement in the file

A. package

B. class

C. object
D. declaration

8) In java thread to thread communication is called ….

A. passing

B. sending

C. messaging

D. calling

9) Every method of a ……….. is implicitly final.

A. static class

B. dynamic class

C. final class

D. abstract class

10) The string is defined in ……… name space.

A. java.Lang

B. java.String

C. java.Char

D. java.Awt

11) A ……… object cannot be modified after it is created.

A. double

B. int

C. string

D. main

12) ……… is a special member function.

A. method

B. class

C. use defined function

D. constructor
13) A …….. class may not have any abstract method.

A. abstract

B. static

C. final

D. public

14) Keyword ………. is always a reference to the object.

A. new

B. this

C. invoke

D. class

15) ……… operators are overloaded for string objects?

A. -,+

B. +,=

C. <<,>>

D. ++,–

16) ……. is a small unit of process.

A. method

B. thread

C. applet

D. steam

17) ……. is valid for if statement?

A. An integer expression

B. A Boolean expression

C. A character expression

D. A legal expression

18) Wrapper class is a wrapper around a ……. data type.


A. normal

B. central

C. primitive

D. concrete

19) …….. statement is valid for array declaration.

A. int number();

B. float number();

C. float number[];

D. count int[];

20) ……. operators which concatenate two strings.

A. +

B. ++

C. –

D. +-

JAVA Multiple Choice Questions and Answers pdf free download ::

January 17, 2017 iqapdf JAVA Multiple Choice Questions Leave a Comment

← 100 REAL TIME INFORMATICA MDM Interview Questions and Answers

100 REAL TIME BOOTSTRAP Multiple Choice Questions and Answers | MCQs →

Interview Questions and Answers pdf free download for freshers experienced MCQs
Real time certification basic asked objective programming on IT & NON-IT Placement
Papers FAQs

This site is protected by wp-copyrightpro.com

You might also like