Tuesday, October 21, 2014

WBUT 5 YEARS JAVA MCQ SOLUTIONS FOR BCA,MCA & BTECH COURSE


2010

i) Which of these is known as short-circuit and operator?
     a) &&,  b) &,     c) ? &,   d) None of these.

ii) A constructor can be inherited using the keyword?
a) Final, b) Static,     c) Super,      d) None of these.

iii)
     int i = 2;
     System.out.println(“welcome”+1+2);
     The output is :

     a) welcome3        b) welcome12
     c) compiler error d) none of these.

iv) To inherit an interface from a class we use the keyword
.................... .
a) extends, b) implements ,c) both (a) & (b), d) none of these.

v) In java applet, ‘Stop ( )’ method can be invoked for a
thread
     a) once, b) twice, c) compiler error, d) not at all.

vi) Dynamic method dispatcher is used for
     a) resolving method overriding
     b) resolving multilevel inheritance
     c) resolving multiple inheritance anomaly
     d) none of these.

vii) JVM stands for
     a) Java Virtual Machine
     b) Java Visual Machine
     c) Java Vision Machine
     d) None of these.

viii) Each time we shift a value to the right using ‘>>’ operator it divides the value by .................... ?
     a) 4,  b) 2,  c) 8,  d) None of these.

ix) Which of the following statement is true regarding constructors?
     a) All cases must be define as a constructor
     b) A constructor can be defined private
     c) A constructor can return a value
     d) A constructor must initialize all the fields of a class.

x)
 int x = 2;
for (x = 0; x < 5; x++)
System.out.println(x);
The output is
a) 0 1 2 3 4      b) 1 2 3 4
c) 2 3 4      d) none of these.
2012
i) A constructor

a) Must have the same name as the class it is declared within

b) is used to create objects

c) may be declared private

d) none of these.

e) a, b, c.

ii) Which of the following may be part of a class definition?
a) Instance variables      b) Instance methods
c) Constructors              d) All of these.

iii) What is the difference between a Java applet and a
Java application?
a) An application can in general be trusted whereas an applet can't
b) An applet must be executed in a browser     environment
c) An applet is not able to access the files of the computer it runs on
d) (a), (b) and (c).

iv) 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 a Java source file
d) It is the code written within the instance methods of a class.

v) What is garbage collection in the context of Java?
a) The operating system periodically deletes all of the java files available on the system
b) Any package imported in a program and not used is automatically deleted
c) When all references to an object are gone, the memory used by the object is automatically reclaimed
d) The JVM checks the output of any Java program     and deletes anything that doesn't make sense.

vi) Consider the following code snippet
String river = new String ("Columbia") ;
System.out.println(river.length()) ;
What is printed ?
a) 6, b) 7, c) 8, d) Columbia,e) River.

vii) You read the following statement in a Java program that compiles and executes
submarine.dive(depth);
What can you say for sure ?
a) Depth must be an int
b) Dive must be a method
c) Dive must be the name of an instance field
d) Submarine must be the name of a class
e) Submarine must be a method.

viii) Consider the following program:

import myLibrary. ;

public class ShowSomeClass

{

// code for the class...

}

What is the name of the Java file containing this proram ?

a) myLibrary.java

b) ShowSomeClass.java

c) ShowSomeClass

d) ShowSomeClass.class

e) Any file name with the java suffix will do.

ix) Which of the following is TRUE?
a) In java, an instance field declared public generates a compilation error
b) int is the name of a class available in the package
java.lang
c) Instance variable names may only contain letters and digits.
d) A class has always a constructor ( possibly automatically supplied by the java compiler )
e) The more comments in a program, the faster the program runs.

x) What is the full form of JVM ?

a) Java Visual Machine
b) Java Variable Management

c) Java Virtual Machine
d) None of these.

2011

i) Which is the integer type among the following ?
a) Float, b) Byte,c) Chard, d)Double.

ii) Which is the wrong statement in automatic type conversion?
I) Two types should be compatible
II) The source type should be smaller than destination
III) type.
The destination
destinaion type
a) I & II
c) II & III
type should be larger
b) I & III
d) None of these.
than

iii) The default constructors automatically initialize all
Instance variables to
a) 0, b) 1,c) – 1, d) none of these.

iv) Which operator is used to create memory to object ?
a) New,     b) Dot, c) both (a) and (b),d) none of these.

v) When you implement an interface method, it must be declared as
a) public, b) private, c) protected, d) none of these.

NB:It must be default access specifiers & it is not equal to public, but consider as equivalent to public. So ans. May be public.

vi) ...................... wakes up the first thread that called
wait() on the same object.
a) Notify, b) Notifyall,c) both (a) & (b), d) none of these.

vii) ......................... abstract method is the only entry point to the thread.
a) suspend(), b) run(), c) resume(), d) wait().



viii)......................... method is called each time your applet's output must be drawn.
a) init(), b) start(),c) paint(), d) destroy().

ix) To extract a single character from a string, we can refer directly to an individual character via the
......................... method.

a) getchars(), b) putchars(),c) CharAt(), d) all of these.

x) ......................... interface defines one method to
recognize the state of an item changes.
a)     keylistener,        b) item listener,
c) focus listener       d) all of these.

2013
i) JVM stands for
a) Java Virtual Machine    b) Java Vision Machine
c) Java Visual Machine    d) none of these.

ii) String str ="ABCD";
System.out.println (str.charAt(2));
The output is
a) C, b) 2,c) exception occurs, d) none of these.

iii) Dynamic method dispatcher is used full for
a) resolving method overriding
b) resolving multilevel inheritance
c) resolving multiple inheritance anomaly
d) none of these.

iv) In Java applet, stop( ) method can be invoked
a) once, b) twice,c) many times, d) not at all.

v) Which of the following statements is true regarding constructors?
a) All cases must define a constructor
b) A constructor can be declared private
c) A constructor can return a value
d) A constructor must initialize all the fields of a class.

vi) What is the return type of read( ) method of
InputStream class?
a) String, b) Float,c) Void, d) None of these.

vii) Which of the following JSP expressions are valid ?
a) <%="Sorry"+"for the"+"break"%>
b) <%="Sorry"+"for the"+"break";%>
c) <%="Sorry"%>
d) <%="Sorry";%>


x)
What happens if Database Updation code is written in
ejbPassivate( ) method and if this method is called ?
a) Exception is thrown
b) Successfully executes the Database Updation code

c)
Compilation error occurs indicating that Database
Updation code should not be written in
ejbPassivate( )

d)
ejbStore( ) method is called.
i) Java bytecode is saved in files with names that end with
a) .class ,b) .code ,c) .java, d) .exe


ii)
An exception is
a) run-time error            b) machine error
c) compile time error            d) none of these.


iii)
From the following which one is not Java primitive data type ?
a) Byte, b) Boolean, c) Short, d) Variant.


iv)
The ability to declare different methods with the same name in a class is known
as
a) Method overloading               b) Method overriding
c) Recursion                  d) None of these.

v)
Which member function of a class is used to create object of that class?
a) Constructor, b) New, c) Object, d) None of these.

vi)
How many default constructor one can have in a class ?
a) 1, b) 4, c)0, d) 2.

vii)
The many catch clauses can a try statement have without finally ?
a) One, b) Any number, c) Zero, d) None of these.


viii)
Which class cannot be instantiated ?
a) Abstract, b) Public, c) Final, d) Protected.


ix)
All exceptions in Java are subclass of
a) Throwable, b) Abstract, c) Error, d) Throw.


x)
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



No comments:

Post a Comment