0% found this document useful (0 votes)
205 views6 pages

Core Java MCQ Unit 4

1. The correct order of an applet's lifecycle is initialized, started, painted, stopped, destroyed. 2. The AWT calls an applet's methods in the order init(), start(), paint(). 3. An applet is a subclass of the component class, which is a subclass of the container class.

Uploaded by

PALLAV MANDVE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
205 views6 pages

Core Java MCQ Unit 4

1. The correct order of an applet's lifecycle is initialized, started, painted, stopped, destroyed. 2. The AWT calls an applet's methods in the order init(), start(), paint(). 3. An applet is a subclass of the component class, which is a subclass of the container class.

Uploaded by

PALLAV MANDVE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

BCCA SEM IV Core Java

UNIt -IV MCQ


Sr.No. Questions A B C D Ans
Applet is Applet is Applet is
started,initiali painted,starte initialized,sta
Which is the correct order of lifecycle in an None of
1 zed,painted,d d,stopped,init rted,painted,st C
applet? the above
estroyed,stop ilaized,destro opped,destroy
ped yed ed
When an applet begins, in which sequence .
init(),paint(),s paint(),sta
2 will the AWT call the methods? Start(),paint() init(),start(),p C
tart() rt(),init()
,init() aint()
Applet class is a subclass of the panel class,
3 which is again a subclass of the ………. object component awt container D
class.
The …………method is called every time
the applet receives focus as a result of
4 scrolling in the active window. init( ) start( ) stop( ) destroy( ) B

Before we try to write applets, we must


make sure that Java is installed properly and
also ensure that either the java
appletviewer( appletrunner( browservi
5 …………….. or a java-enabled browser is viewer( ) B
) ) ewer( )
available.

Applet runs inside the browser and works at


6 TRUE FALSE A
client side
Which is a special type of program that is
Package None of
7 embedded in the webpage to generate the Applet Browser B
the above
dynamic content?
When an applet is terminated which of the
stop(),paint(), destroy(),stop destroy(),stop stop(),dest
8 following sequence of methods calls take D
destroy() (),paint() () roy()
place?
Which method is called only once during
9 the run time of your applet? stop() paint() init() destroy() C

The APPLET tag is used to start an applet


10 from both an HTML document and from an TRUE FALSE A
applet viewer.
Which of these classes is not related to
input and output stream in terms of
11 File Writer InputStream Reader A
functioning?

word
12 Applet can be embedded in a RTF file html file gif file C
document
Which of these classes are used by character Writer and
13 InputStream ReadStream InputOutp B
streams for input and output operations? Reader
utStream
Which of these is a type of stream in Java? Integer Long
14 Short stream Byte stream C
stream stream
Which of the following methods not
15 write( ) skip( ) close( ) flush( ) B
included in OutputStream class.
Which of the following method(s) not
16 available( ) reset( ) flush( ) close( ) C
included in InputStream class.
Which of these is a method to clear all the
17 clear() close() B
data present in output buffers? flush() fflush()
Which of these methods are used to read in readFileIn
18 get() read() scan() B
from file? put()
Which of these methods belongs to
19 Graphics class? display() paint() drawString() transient() C

20
which of the following statements about An applet is a An applet is a An applet is a An applet
21 hierarchy of the class java.awt.Applet is kind of kind of kind of is a kind C
incorrect? container window component of panel
22 The class at the top of the AWT hierarchy is component window container frame A
On invoking repaint() method for a
23 component, the method invoked by AWT draw() show() update() paint() D
is:
The ………… attribute of applet tag
specifies the amount of horizontal blank SPACE=pixe HSPACE=pi HWIDTH=pi HBLANK
24 B
space the browser should leave surrounding ls xels xels =pixels
the applet.
We can change the text to be displayed by
<PARAM
25 an applet by supplying new text to the <EDIT> <CHANGE> <REPLACE> D
>
applet through a ………… tag.
Which of these classes defined in java.io
and used for file-handling are abstract?
InputStream
26 PrintStream Only A Only C A and C A and B C
Reader
FileWriter

Which of these classes are used by Byte InputOutputS All of the


27 InputStream Reader A
stream for input and output operation? tream mentioned
Which of these class is used to read FileInputStre
28 FileReader FileWriter InputStrea A
characters in a file? am
mReader
……………. class is used to increase the
DataInputStre FileInputStre PipeInput
29 efficiency of input operations. BufferedInput C
am am Stream
Stream
File Not
Which exception is thrown by the read( )
30 Exception IOException ReadExceptio Found B
method of InputStream class.
n Exception
The class DataInputStream
SequenceInpu InputStrea
31 extends…………….. and implements the FileInputStre FilterInputStr C
tStream m
interface DataInput. am eam
FileInput
Which of these exception is thrown by FileNotFound
32 IOException FileException OutputEx A
close() and read() methods? Exception
ception
Which of these values is returned by read()
33 method when end of file (EOF) is 0 1 -1 NULL C
encountered?
Which of these exception is thrown in cases
when the file specified for writing is not
FileNotFound FileInputE
34 found? IOException C
FileException Exception xception

Which of these classes contains the methods BufferedOutp FileBuffer


35 FileStream FileInputStre C
used to write in a file? utStream Stream
am
The graphics class provides methods to
draw a number of graphical figure including
i, ii and iii ii, iii and iv i, iii and iv All i, ii,
36 i) Text ii) Lines iii) Images iv) D
only only only iii and iv
Ellipse

Applets can't
An applet
load libraries
Which are the common security restrictions can't read Applets can Both A &
37 or define D
in applets? every system play sounds B
native
property
methods
38

<PARAM <PARAM
<PARAM <PARAM
NAME="x" VALUE=
39 Write the syntax of param tag NAME=x VALUE=y C
VALUE="y" "y"
VALUE=y> NAME=x>
> NAME="
x" >
read()
List two primary methods for reading bytes write(int) read() length()
40 read(byte[]) B
from an input stream write(byte[]) write() charAt()
read()
List two primary methods for writing bytes write(int) read() length()
41 read(byte[]) A
to an output stream write(byte[]) write() charAt()
Filereader
fileReader fr FileReader fr
FileReader fr fr = new
How will you create the object for reading = new = new
42 = new Filereader C
from file xyz.txt fileReader("x FileReader("x
("xyz.txt"); ("xyz.txt")
yz.txt"); yz.txt");
;
FileWriter Filewriter
filewriter None of
How will you create the object for writing fw=new fw=new
43 fw=new(“xyz the A
into file xyz.txt FileWriter("x Filewriter("xy
.txt”); mentioned
yz.txt"); z.txt");
none of
directory in
44 Which of these is specified by a File object? a file in disk directory path the C
disk
mentioned
<applet
param=Te
<applet <applet> <applet
Which of the following applet tags is legal st.class
class=Test code=Test.cla code=Test.cla
to embed an applet class named Test into a width=20
45 width=200 ss width=200 ss width=200 D
webpage? 0
height=100> height=100> height=100>
height=10
</applet> </applet> </applet>
0>
</applet>
User I/O
Applets is
Applets do Applet uses
should be run accomplis
not need a the interface
46 Analyse what is not true about applets? under a java hed with D
main() provided by
compatible java's
method AWT
browser stream I/O
classes
public class abstract
public class
MyApplet class
MyApplet
which one of the following is a valid public Applet extends MyApplet
47 extends
declaration of an applet? MyApplet { applet extends
java.applet.A
implements java.apple
pplet {
Runnable { t.Applet {
<param
If you want to assign a value of 27 to the
number = <param = name=mar
variable marks, then which of the following
48 getParameter( <number=27 marks ks D
lines can be used within an <applet> tag.
27) > value=27> value=”27
”>
49
What will be the output of the following
program?
import java.io.FileWriter;
import java.io.IOException;
class Write
{
public static void main(String[] args)
contents of str
throws IOException display “A
will be runtime
50 { quick brown compile error A
written into error
String str = "A quick brown fox"; fox”
xyz.txt
FileWriter fw=new
FileWriter("xyz.txt");
for (int i = 0; i < str.length(); i++)
fw.write(str.charAt(i));
fw.close();
}
}

What will be the output of the following


program? Suppose there is file abc.txt
containing text "Hello World!"?
import java.io.*;
public class Test {
public static void main(String[]
args)throws Exception
{
Compile
51 File file = new File("D:\\Jstud\\abc.txt"); Hello World! Hello World! C
error
BufferedReader br =
new BufferedReader(new
FileReader(file));
for(String st; (st = br.readLine()) != null ; )
System.out.println(st);
}
}
What will be the output of the following
program? Suppose there is file abc.txt
containing text "Good Morning"?
import java.io.*;
public class sample {
public static void main(String[] args)
throws Exception
Good compile
52 { Good Morning C
Morning error
FileReader fr = new
FileReader("abc.txt");
for (int i;(i=fr.read()) != -1; )
System.out.print((char) i);
}
}

What will be the output of the following


Java program? (Note: file is made in c
drive.)

import java.io.*;
class files
{
53 java true java false \java false \java true C
public static void main(String args[])
{
File obj = new File("/java/system");
System.out.print(obj.getParent());
System.out.print(" " + obj.isFile());
}
}

import java.io.*;
class test
{
public static void main(String args[])
54 { java/system java /java/system system D
File obj = new File("/java/system");
System.out.print(obj.getName());
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy