0% found this document useful (0 votes)
144 views

Java Fundamentals: X (X ) ? (Y+x) : (Y-X)

This document contains multiple choice questions about Java fundamentals including questions about arrays, data types returned by methods, valid Java class and package declarations, the purpose of the JVM, and more. There are 19 questions in total testing core Java concepts.

Uploaded by

rony roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views

Java Fundamentals: X (X ) ? (Y+x) : (Y-X)

This document contains multiple choice questions about Java fundamentals including questions about arrays, data types returned by methods, valid Java class and package declarations, the purpose of the JVM, and more. There are 19 questions in total testing core Java concepts.

Uploaded by

rony roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

OBIECT ORIENTED PROGRAMMING WITH AVA

JAVA FUNDAMENTALS
Multiple Choice Type Questions
1. Consider the following statements: WBUT 2006)
int x=10, y= 15;
x=(x<)?(y+x):(y-x);
what will be the value of x after executing these statements7
a) 10 b) 25 c) 15 e) Error, cannot be executed
d) 5
Answer: (6)

2. Which of the following are valid array declarations! definitions? WBUT 2008]
1) int iArray 2[1;
2) int iArrays[] new intf10];
3) int iArray4 (10) new int[10]:
a) 1 b) 2 c)3 d) none of these
Answer: (6)

3. i f (check(storeNum)! = null) { ) WBUT 2009]


Referring to the above, what data type could be returned by method check ()?
a) boolean b) string c) char d) byte
Answer: (c)

4. int values [] = (1, 2, 3, 4, 5, 6, 7, 8) WBUT 2010, 2018]


for (int i=0 i< Xi +*i)
System.out.println (values [il);
"values"?
Referring to the above, what value for X will print all members of array
b) 7 c)8 d) 9
a) 1 declaration
e) None, since there is a syntax error in the array
Answer: (c)

5. JVM iss
WBUT 2010, 2018]
a) A java package b) A java compiler c) A system software
e) None of these
d) A java interface
Answer: (c)

compile and run the program? wBUT 2011]


6. What is the result of attempting to
public class Test
arg) t
public static void print (Integer
System.out.print ("Integer")

public void print (int arg) (


System.out.print ("int");

s t a t i c void main (String (i arg) (


public
MCA JAVA-5
POPULAR PUBLICAIIONS

print (new Integor (3))


/ end of main
)/1 end of tost class
a) int b) integer
c) compilation error
d) none
d) none of
Answer: (b) th
en
7. Which code declares class B belong to the packago1.mypackage
b)
apackage packago1. package mypackage import
package1. WBUT 201
c)package package1.mypackage.5 d) package package1.mypas
Answer: (b) ckage
S. doublo x =
0;
X(check ( ). equals ("1"))? gotSales (): ( ); nextStore NBUT 201
method check ( ) as shown above?
What datatype could be returned by c) string d) byte
a) int b) Boolean
Answer: (6)
9. Which one of the following is NOT a valid java.lang.String declaration?
a) String myString = new String ("Hello"
b) String myString new String (5);
WBUT 2012
c) String ccde = "cde";
d) String myString = new String ( );
Answer: (6)

10. Local variclcs it 'ava are stored in


b) Native area c) Method Area
WBUT 2012
d) Stack
a) Heap
Answer: (d)

11. Consider ine foiowing code WBUT 2012


package B;
public class A {
int getSquare (int i) (return i * ij}

Referring to the above, what classes can access method getSquare () in Class
A?
a) class A
b) class A and classes in package B only
c) class A, all subclasses of A and
classes in package B only
d) class A and its subclasses only
Answer: (b)

12. Abstract classes [WBUT 2013]


a) cannot be instantiated but can be inherited
b) cannot be instantiated or inherited
c) can be instantiated but not inherited
d) can be instantiated and inherited
Answer: (a)
MCA JAVA-6
OBJECT ORIENIED PROGRAMMING
program
WITHJAVA
Java
13.A can have i
multiplo main() methods WBUT 2013]
but
only one main( ) in one class
an have mutple main( )
ban have only one static methods
main( )
in all the classes
method in any class
c)othods must be
non-static if inside the same class
and other
main()
only
d) can o n have main( ) methods in public classos
Answer: (a)

program can have


A Java
14. a )only o n e
public class in one file of the WBUT 2013]
same name as that class
b)multiple public classes in one filo, but the
file must be named after
of them any one
as many public classes in one file, but the file must be named after any
of them one
d) public classe in files that only have one class
Answer: (a)

15.'Java'is a call to the jvm working on


a).class file b) java file [WBUT 2013]
c).obj file d) none of these
Answer:(a)

stands for
16. JIT WBUT 2013]
a) Just-in-time compiler b) java in time compilation
c)java interpreter timer
d) none of these
Answer: (a)

17. JVM is the WBUT 2013]


a) java compiler b) java interpreter c) all of these d) none of these
Answer: (d)

18. What is the result of attempting to compile and run the program> WBUT 20141
public class Test {
public static void main(String Ii args)
int x = 0, y = 0;

x =
5+ y++;
System.out.print ( x + " +y)

x = 0;
Y =0

5+++Y}
S y s t e m . o u t . p r i n t( x + " +y);

//end of main
W/end of test class
a) 5161 b) 6161 c) 671 ) none of these
Answer: (a)

MCA JAVA-7
POPULAR PUBLICATIONS
WBUT 2016
19. int i 2
("welcome"i + 2)1
Outprintln
The output is c) compilor orror d) nono of
thes
a) wolcome 4 b) wolcome 22
Answer: (c)
programs roo
will compile and run the WBUT 2016
at happon when vou

public clas nyclase (


Public s t a t i c void main(String argo
world") ; } }
3yotom.out.println
("hello
b) hollo world

a) compilation error d) Hello World

c) Hello world
Answer: (a)
Machine
WBUT 2016
21. JVM stands for Visual
b) Java these
a) Java Virtual Machine
c) Java Vision Machine
d) none of
Answer: (a)
WBUT 2016)
to define a constant? d) None of these
22. Which keyword is used in java c) Public
a) Static b) Final
Answer:(b)
the readLine() method?
data line by line using [wBUT 20171
Z3.
Which class can be used to read InputStreamReader
b) these
a) BufferedReader
d) none of
c) DatalnputStream
Answer: (c)
WBUT 2017, 2018]
Java source code to d) none of these
a
24. The JVM compiles c) Unicode
executable code
a) object code b)
Answer: (d)
WBUT 2018]
25. JRE stands for Engine
Engine
b) Java Remote
a) Java ResearchEnvironment d) None of these
Runtime
c) Java
Answer:(c)
Questions
ShortAnswer Type
WBUT 2006]
structure.
1. Draw the Java heap
Answer: data area from which memory
for all class
that is the runtime
The JVM has a heap JVM start-up.
allocated. lt is created at the
instances and arrays are
with the following VM options:
The heap size may be configured
-Xmx<size> - the maximum Java heap size
to set

MCA JAVA-8
OBJECT ORIENIED PROKGRAMMING WIIH JAYA
OPERATORS AND FLOW OF CONTROL
Multiple Cholce Type guestions
. int i WBUT 2009, 2010, 2018]
int i0 i<14; i*+)
if(i«10}
i2i

Syetm.out .println (*" +j+ *i" +i)


is wrong
vith the above code?
with
what
a Integer "T is not initialized
b nothing
wOU cannot declare integer i inside the for-Hoop declaration
wau cannot printinteger values without converting them to strings
) you
Answer:(3)

Which access modifier is used to restrict the methods scope to itself and stil
allows other classes to subclass that class$? WBUT 2009
)private b) final c) protected d) final
Answer: (C)

of the following program? WBUT 2009]


What is the output
Trial (
class
public
i n t x:
public static void main (Stzring args t 1)
8:
Bystem.out.print ("The value of x is" x);

value of x is 8 b) The program prints the value of x is 0


a) The program prints the
d) None of these
c) The program will not compile
Answer: (c)

4. What will be the output? WBUT 2011]


public class Ques
private int i
new Ques ();}
public Ques incre () {i ++j return
("i=" +i) ;}
public void show () { System.out.println
(
public static void main (String[largs)
Ques q1 = new Ques ();
q.incre().incre().show ();}} c) compilation error d) i 0
a) i=2 b) i = 3

Answer: (d)

MCA JAVA-17
POPULAR PUBLICATONS
5. Consider the following statements: WBUT 2
int a-15, b«20
a((acb) ? (a+b):(a-b))
nat will be the value of a after executing these stato
c) 15
a) 10 b) 25 be executed
d))5 o) orror, c a n n o t

Answer: None of the above. Actual answer Is a .

6. int a -
2
for (a 5 a + *)
System.out.println (a)i

The output is b) runtime exception


WBUT 2015
a) compiler error d) 234
c) infinite loop
Answer: (a)

7. int i = 2 i);
(i WBUT 2015
+++
System.out.println

The output is c)3


d) compiler error
b) 4
a) 5
Answer: (b)
WBUT 2015, 20181
followijg statements:
8. Consider the
int arr[l = new int[3]1
arr[31= 7
Systea.out.println (arr[31) ;

The output is
b) 7
a) 3 d) runtime exception
c) compiler error

Answer: (d)

9. ink k = 5
WBUT 2016
+ k + 5)
Systea.out.println ("Hello"
The output is
a) Hello 10 b) Hello 55 c) Hello 10 d) compiler error
Answer: (b)

= 3, q = 6;
WBUT 2016]
10. int p
System.out.println (p + + + q)i
b) 10 c) 11 d) compiler error
a) 9
Answer: (a)

11.int p 3 WBUT 2016]


For (p= 0; P <107 p =p+2);
System.out.println(p);
a) 0 24 658 b) 2 4 6 8 c) 10 d) 4 6 8 10
Answer: (c)
MCA JAVA-18
OBJECT ORIENTED PROGRAMMING WITH JAVA

CLASSES AND OBJECTS


Multiple Cholce Type guestions
Alhat is the error in the
abstract c l a s s xY following class definition? WBUT 2006]

tract sum int x, int y)


(
a) Class header is not defined properly b) Constructor is not defined
c) method not defined properly d) no error
Answer: (c)

2 .class A
int i , i, k WBUT 2007]
public A (int ii) ti =
ii; )
public A )
k 1

Referring to the above, which of the following instantiates an object of class A?


a) new A (this); b) A a new A (3);
c) A (3) a; d) A a = new A (4, 8);
Answer: (6)

3. Objects can be cast to another class when which among the following is case?
a) Both classes are direct subclasses of the same, superclass
b) The source class is not abstract or static
WBUT 2007]
c)The target class is a subclass of the,source class
d) Both classes are subclasses of the same abstract superclass
Answer: (c)

4. How may default constructor(s) can be had in a class? [WBUT 2007]


a) 1 b) 4 c) 0 d) 2
Answer: (c)

5. class A {
[WBUT 2008]
int i, j, k;
public A (int ii) t i = ii; }
public A )
k=1

NGrerring to the above, what code instantiates an object of class A?


a) new A(this); b) A a new A(3); c) A (3) a; d) A a = new A (4, 8);
Answer: (b)
MCA JAVA-21
POPULAR PUBLICATIONS
mypackage.financial package
bolong to the
.Which code declares class A to financia, WBUT 2008, 2010, 2012
a) packago
package mypackage;
b) import mypackage.
c) import mypackage.financial.A;
d)package mypackage.financial;
Answer: (Cc)
WBUT 200
7. Return of class, constructor is class of these
type type itself d) none

a) int b) void c)
Answer: (d)
keywords relate to?
WBUT 2009
8. What do the 'public' and 'private' b) garbage collection

a) typing d) access restriction


c) polymorphism
Anwer: (d WBUT 2009
of the True?
9. Which of the following all abstract methoas
method is to be found
that is abstract must be containing
class
a) A indicates that the body of a me in CIC++
T h e fnal keyword typically
written in non-java language,
elsewhere. The cnde is
cne copy ofthatvarla to all otker
static variable indicates there is only accessible
c)A iroicates that it is
defined as private
d) A method
classes in the some package
AnSwer: (C)
constructors
statements is true regarding WBUT 2009]
10. Which ofthe following constructor
must define a
a) All cases
can be declared private
b) A constructor can return a value
c) A constructor must initialize all the fields of a class
constructor
d) A
uSwer: (a) and (b)
WBUT 2011
to
11. super() is used
constructor
constructor within subclass
superclass constructor
a)access
method within
subclass
superclass
b)access

and (b)
c) both (a)
these
d) none of
Answer: (a) that the
code segment (assuming
the following
the output of WBUT 2012]
12. What will be address location 2345)?
stored in the
object 'ct' gets Test (
class Class
public string to
String ( ) }
return
" c l a s s Test ";

args) {
public static void main (String [
class Test ct
=
new Class Test ();
System.out.println (ct);

MCA JAVA-22
OBJECT ORIENIED PROGRAMMING WITHJAYA

al Class
Test @2345
b) Error
h)A WRONG PROGRAM
Ansmer: ( b ) ,

CODE
c) Class Test
d) ct

Wnticstatement
h about
static
3
inner classes may inner classes is tru? WBUT 2012]
aatic inner classes may access any of the enclosing
classes members
Datic inner classes do notnothave
c) stati
be Instantiated
outside of the enclosing class
ner
d) static inner. classes are
a reforenco to the enclosing class
created when the
tnswer: (d) enclosing class is loaded
default' access applies
14.
package only
a) with
cl the same as public access b) across all packages wBUT 2013]
Answer: (a) d) none of these

15. A
static member of a class
a) can be accessed in all main() methods WBUT 2013
b) can be accessed only outside main()
c)c a n be methods
accessed only in main() methods
d can be only accessed in one
that are static
main( ) method in any one
Answer: (c) program

16. Vector V= new, ector (20, 20) means


al yhas initial capacity 20, and will wBUT 2013
always have capacity 20
bl v has initial capacity 20 and grows by 20
c)v has initial capacity
20, the last 20 is ignored
d) there is no such constructor in the vector class
Answer: (b)

17. What will be the output:


public class Test ( WBUT 20141
int i;
public Test ()
(System.out.println("Hello "" i = "+i)
public Test (int w)
this()
public static void main(String args
Test obj
[1)
//end of main
new
Test(50)
=

//end of test class


a) Hello i=0 b) Hello i= 50
c) Compilation error d) none of these
Answer: (d)

MCA JAVA-23
POPULARPUBLICATIONS
18. What will bo the output WBUT 2014
class A
String sl "A.n1")
String s2 "A.s2"

Class B extends A
String sl "B.s1"
main (String [] arga) (
s t a t i c void
public class Test ( \public
B b1 new B()
A a1 bl;
S y s t e m . o u t . p r i n t l n ( a l . s 1 + " " + a 1 . a 2 )

/end main
class d) none of those
//end of test
b) B.s1 A.s2 c) A.s1 B.s1
a) A.s1 A.s2
Answer: (a)

methods are incorrectly declared,


which are thoy? wBUT
[WBUT 2014)
2014
19. Three of the
abstract class abstractA
public void test1();

public final void test2() 0


public s t a t i c void test3() (
abstract static
void test4()
public
test5 ()
abstract final void
public
and test5
test2 and test4
b) test2, test4
a) test1, d) none of
these
c) test1, test4 and test5
Answer: (c)
error:
WBUT 2014]
declaration results in compilation
20.Which class
class Z{
void m() 1/1ine 1
abstract class A( )
1/1ine 2
final class B() 1/line
private class C{)
) //1ine
class D
public

c)line 3 d) line 3 and line 4


b) line 2
a) line 1
Answer: (d)
the program WBUT 2014]
to compile and run
21. What is the result of attempting
class B
private String name;
public B(String s) {
name = 8

protected void finalize () {


MCA JAVA-24
OBIECL ORILNID IHORAMMINM WIM IAYA

syst.em.out.print (name)

E
pub
Btatic void m() (
Bx1 new B("X")
By1 new B("y")

oublic class Teat

public Btatic vo roid main (Stringll arg»)


E.m()

S y s t e m . g o ( )

//ond of main
test clase
}//end o f

b) prints YYXX c) prints nothing d) none of these


Answer:(d)

class
ofa methods
Contract
is meant by WBUT 2015, 20171
22. of in the class b) number of data fields in the class
number
constructors in the class d) none of these
Answer: (a)

returns value of type WBUT 2017


constructor
23. b) void c) class type itself
a) int
as no specification of return type is needed
d) nothing,
Answer: (d)

Which one ofthe following cannot be used as a method modifier? WBUT 2017]
a) Private
b) Generic c) Protected d) Synchronized
Answer: (d)

Which 0f the following is used to detect the selection made by a user on a

Choice component? WBUT 2017]


a) ActionListener b) ItemListener
c) MouseListener d) SelectionListener
Answer: (b)

26. Which class cannot be initialized? WBUT 2018]


b) Public c) Final d) Protected
a) Abstract
Answer: (a)

MCA JAVA-25
OBJECI ORIENIED PROGRAMMING
WITH IAYA

INHERITANCE AND POLYMORPHISM


Multiple Choice Type Questions
method dispatcher is useful for WBUT 2006, 2008, 2009, 2015]
1.

resolving method overriding


D y n a m

b)
a) resolving multilevel inhe
eritar anomaly
c) resolving multiple inheritance anomaly
none
of these
d)
Answer: (a)

todeclare different methods with the class is known


2 Theability same name na
WBUT 2007]
a ) Overriding b) Overloading c) Recursion d) None of those
Answer: (b)

Multiple inheritance is implemented in Java by WBUT 2007


3 Extending two or more classes
Extending one class and implementing one
on or more interfaces
two or more interfaces
c)Implementing

d All of these
Answer: (c)

Which of the following statements about an interface is incorrect?


WBUT 2008, 20171
a)It can be partially implemented by a class
byan
implemented interface
b) It can be classes
c It can be implemented by several
class can implement several interfaces
d) A particular
Answer: (d)

only WBUT 2009, 2015]


can define
5. An interface b) final field
a) abstract class
field
c) abstract method d) abstract method and final
Answer: (d)
WBUT 2011]
6. Multiple inheritance is implemented in Java by
classes
a) extending two or more one or more
interfaces
class and implementing
b) extending one

c)implementing two or more intertaces


d) all of these
Answer: (b) & (c)

MCA JAVA-55
OBJECT ORIENTED
PROGRAMMING WITH JAVA
STRING AND STRING BUFFER
Multiple Choice Type Questions
h of the following describes the
1. W h i c h

difference between
? StringBuffer and
GtringtriagBuffer is used only to buffer data from an input or output stream
a )S t r WBUT 2007, 2008]
b)
Buffer
StringBut allows text to be
changed after instantiation
holds zero
length strings
StringBuffer

StringBuffer
d supports Unicod
4nswer:
(b), (c) and (d)

nublic static void main (String l] s) WBUT 2010


2. 2 String nl, n2, n3
3 nl "n1";
4 n2 "n2"
5 "n3"
6
7 String n "inner"
8 n2 nl;
9
10 n3 null;
11)
Unw many instances
of
the String will eligible for garbage collection after line 10 in
code snippet is executed?
the above d) 3
a) 0 b) 1 c) 2
will not compile
e) The code
Answer: (e)
WBUT 2010]
Unicode is
3. Size of c) 16 bits d) 15 bits
a) 2 bits b) 8 bits

these
e) none of
Answer: (c)
class is WBUT 2011
4. Difference between String and StringBuffer cannct be
be extendable but StringBuffer object
a) String object
can

extendable can be expandable


be extendable but StringBuffer object
b) String object can
c) both are same
d) none of these
Answer: (d))

MCA JAVA-79
POPULAR PUBLICATIONS8
6. What will be output:
NBUT 20
args) (
publio olass Test l
(String
main
Dublia s t a t i a void

Btring "
Buffer (),
Integerx 5 =
new
String

Buffer
sb
Btring
if (x 15)
.Goncat ( "Hi")

else s b . a p p e n d( " H e l l o " )

Byatem.out.print( s s b )

)//end of main
b) hello
//end of test olass
d) no output
a) HI
c) compllatlon error

Answer: (d)
WBUT 2015
6.String a"3"
System.out.println (a);
The output is b) a
d) runtime exception

a) 3
c) compiler error

Answer: c) (WBUT 2019


7.Strings "INDIA"
System.out.prntln(s.charAt (2))1
d) exception occurs
The output is c)N
a) D
b) 2
Answer: (2) wBUT 2016
s1 "java"
8.String
System.out.println(s1.indexof ( 'v')) d) none of these
b) 2
c)3
a) 1
Answer: (b) WBUT 201
9. S t r i n g s="Hello"
System.out.println(s.charAt(0)); d) none of these
c) error

a)H b)h
Answer: (a)
WBUT 2016
10. S t r i n g S="5"
System.out.println (s.charAt (0));
d) none of these
c) error
b) S
a) 5
Answer: (c)

MCA JAVA-80
OBJECT ORJENTED PROGRAMMING
WITH JAVA
ringBuffer diffe from 'String'?
H o wd o e s
oes
ngBuffer is used only to buffer data from an input or WBUT 2017]
StaBuffer holds allows text to be
changed after instantiation
output stream
GtringBuffer zero
length strings
aStrinBuffe supports Unicode
Answer:(b)

nsider the following statement:


String s = BCAD-6023"; WBUT 2017
System.out.printin (s.chartAt (2));
Theoutput is
a) C
b) A
c) Exception error d) 2
Answer: (b)

13 s t r i n g s e " s
.out.prinatln(s) WBUT 2018]
s t e a .

The output is
b) "s"
a) s c) Compile error d) Runtime error
Answer: (c)

L Short Answer Type


Questions
Wite a program to implementa stack using the built-in class in Java.
.
WBUT 2007, 2008]
OBILLI ORIENILD IROKMAMMItK, WI0IAYA
EXCEPTION HANDLING
Multlple Cholce Type guestlons
Which of the folowing is used
as a part of method signature in Java?
a) throw
WBUT 2008, 2017
c) try b) throws
Answer: (b) d) flnally

public int m1(int x)


2.
int count 1
try
count+a
count m2 (count)
count+

catch ception e) (count -=x1)


return count

Oafering
Refe to the above, when m1(2) is Invokod, m2() throws
Exception andd m1() returns which one of the following?
an
Arithmetic
a) 1 WBUT 2010]
b) 2
c) 3 d) 4
e) The system will exit
Answer: (a)

3. Delegation model is associated with


a) Exception Handling WBUT 20101
b) Garbage Collection c) AWT
d) Event Handling e) None of these
Answer: (a) and (d)

4, int i= "hello" ; what type of exception java throws?


WBUT 20111
a) llegalArgumentException b) NumberFormatException
c) IntegertoStringCastingException d) CastingException
Answer: None of the above. Compilation error: incompatible types.

5. How you have a "try" block that invokes methods that throw two different
exceptions? WBUT 2012]
a) catch one exception in a "catch" block and the other in a "finally" block
b) setup nested "catch" blocks for each exception
c) catch one exception in a "catch" block and the other via the return value
d) include a "catch" block for each exception
Answer: (d)

MCA JAVA-87
POPULAR PUBLICATIONS
WBUT 201
6.What will be the output:
publie clans Tent ( a
publie etatic void main
(String
System.out.print ( " 1 " ) 1

try
returnn
(Except ion e)(
catch yBtem.out.print ("2")7

finally
System.out.print ("3")1

System.out.print ("4")
/ / e n d of main
class b) 14
) / / end of test
d) 13
a) 1234
c) 134
Answer: (d
WRIJT 2014
7. Given the following code
File f new File ( 'myfile.myfile.txt" to be in the
nderlying
created Und.
to De
the file "myfile.txt
will cause
method
operating system? b)f.closel):
a) f.write(); of these
d) none

c) f.flush();
Answer: (d)
o1
OBJECT ORIENIED PROGRAMMING
WITHJAVA
THREADSS
Multiple Cholce Type Questions
oad can bo accessed using
Doad
thre

b) notifyl) WBUT 2006]


a)start() c) recreate 0 d) none of these

ad
2 T h em e t h o d
USed in Java which waits for the thread to
die is
) b) destroy() WBUT 2007
al(a)
wait(
c) dief) d) join(
Ansner:(d)

Synchroniza nization between two or more


than two threads is done by the keyword?
b) Synchronized
a ) S y n c h r o n i z a t i o n

WBUT 2007]
c)Synchronize d) None of those
Answer:(b)

Jar which circumstances will a thread stop?


4Unde herun() method that the thread is executing ends WBUT 2009]
ab) The call of the start() method of the thread object returns
c) The suspend() ethod is called on the thread object
ait( ) method is called on the thread object
Answer: (a)

one of the following statements is FALSE? WBUT 2010]


lJava supports multi-threaded programming
hi Threads in a single program can have different priorities
Multiple threads can manipulate files and get user input at the same time
Two threads can never act on the same object at the same time
el Threads are created and started with different methods
ASwer: None of the answers are FALSE in some aspects. However answer c is close to
FALSE. It may happen that in a multi threaded environment one thread may wait for the
other to complete.

6. The method used in Java which waits for the thread to die is WBUT 20111
a) waitt) b) destroy() c) diel) d) join)
Answer: None of the above. The join method waits for another thread to finish (not die).

1. Which one of the following is a limitation of subclassing the Thread class?


a you must catch the Thread Death exception WBUT 2012]
b) you must implement the Threadable interface
o) you cannot have any static methods in the class
) you cannot subclass any other class
Answer: (d)

MCA JAVA-99
OBIECT ORIENTED
PROGRAMMING WITH JAVA
APPLETS
Multiple Choice Type Questions
.mmediate superclass of the Applet class is
1. The

a) Panel b) Object c)Interface WBUT 2007, 2011]


Answer: (a) d) Window

java applet, start( ) method may be invoked


2.Ina) ked
WBUT 2007, 2016]
Only o n c e
b) Twice c) Many times d) None of these
Answer: (c)

.shich one of
3 .Whi the following is a valid declaration of an applet?
a a) public class MyApplet extends java.applet.Applet
Java.applet.Appl { WBUT 2008, 2010, 2010
) public Applet MyApplet
Oublic class MyApplet extends Applet implements Runnable
c) public
d abstract class MyApplet extends java.applet.Applet(
d) abstract

e Class MyApplet implements Applet{


and (c)
Answer: (a)

Which code segment loads and plays a sound in an applet? WBUT 2012]
a) get Appilet Context ()-get Audioclip (new URL (get Document Base (). To
string ()+ "jawas.wav").start()
b) Play) getDocumentyBase (), "jaws.wav);
c) getAudioClip (new URL (getDocumentBase (). toString ()+ "fjaws.wav")).
Play ():
dget AppletContext (). Play Audio (new URL (getDocumentBase ( ). toString
()"jaws.wav"));
Answer: (a)

5. AWT stands for


WBUT 2013
Toolkit b) Abstract Windows Toolking
a) Abstract Windowing
c) Abstract class Windows
Timer d) Applet in Windows Threads
Answer: (2)

L Short Answer Type Questions


WBUT 2007]
1. Why is a user defined applet class declared as public?
Answer: when it is
that it can be accessed outside
run on
Applet class should be declared public so

browser or through appletviewer too.

MCA JAVA-117

You might also like