1
Ques on Bank
Unit-5
1. Java I/O is used to process the?
(a) input
(b) output
(c) Both A and B
(d) None of the above
2. Which of these is used to perform all input & output opera ons in Java?
(a) classes
(b) Methods
(c) streams
(d) Variables
3. What does AWT stands for?
(a) All Window Tools
(b) All Wri ng Tools
(c) Abstract Window Toolkit
(d) Abstract Wri ng Toolkit
4. Which of these is a type of stream in Java?
(a) Long stream
(b) Byte stream
(c) Short stream
(d) Integer stream
5. Which of these classes are used by character streams for input and output opera ons?
(a) InputStream
(b) Writer
(c) ReadStream
(d) InputOutputStream
2
6. Which of these class is used to read from byte array?
(a) ArrayInputStream
(b) InputStream
(c) BufferedInputStream
(d) ByteArrayInputStream
7. When comparing java.io.BufferedWriter and java. io.FileWriter, which capability exist as a method in only
one of two ?
(a) flushing the stream
(b) closing the stream
(c) wri ng to the stream
(d) wri ng a line separator to the stream
8. System class is defined in
(a) java.io package
(b) java.awt package
(c) java.u l package
(d) java.lang package
9. The package contains a large number of stream classes that provide capabili es for processing all types
of data.
(a) java.awt
(b) java.io
(c) java.u l
(d) java.net
10. State whether the following statements about the stream in Java.
i) The two basic streams used are the input and output streams.
ii) Filters are used to read data from one stream and write it to another stream.
(a) True, True
(b) True, False
(c) False, True
(d) False, False
3
11. Can we perform file handling in Java by Java I/O API?
(a) True
(b) False
12. In java, how many streams are created for us automa cally?
(a) 2
(b) 4
(c) 3
(d) 5
13. Which of these classes are used by Byte streams for input and output opera on?
(a) Reader
(b) InputStream
(c) InputOutputStream
(d) All of the men oned
14. Which method is used to write a byte to the current output stream?
(a) public void flush()throws IOExcep on
(b) public void close() throws IOExcep on
(c) public void write(int)throws IOExcep on
(d) public void write(byte[])throws IOExcep on
15. Which excep on is thrown by read() method?
(a) IOExcep on
(b) SystemExcep on
(c) InterruptedExcep on
(d) SystemInputExcep on
16. Which of these is used to read a string from the input stream?
(a) get()
(b) read()
4
(c) getLine()
(d) readLine()
17. Which of these class is used to read characters and strings in Java from console?
(a) BufferedReader
(b) StringReader
(c) InputStreamReader
(d) BufferedStreamReader
18. Which of these methods can be used to wri ng console output?
(a) print()
(b) println()
(c) write()
(d) all of the men oned
19. Which of these class contains the methods print() & println()?
(a) System
(b) System.out
(c) PrintStream
(d) BUfferedOutputStream
20. Which of these class is used to read from a file?
(a) FileInputStream
(b) InputStream
(c) BufferedInputStream
(d) BufferedFileInputStream
21. The InputStream class defines methods for performing input func ons such as
i) reading bytes
ii) closing streams
iii) skipping ahead in a stream
iv) flushing streams
(a) ii, iii and iv only
5
(b) i, ii and iii only
(c) i, iii and iv only
(d) All i, ii, iii and iv
22. Which of these interface package? is not a member of java.io
(a) FileFilter
(b) DataInput
(c) ObjectFilter
(d) ObjectInput
23. Which of these class is not related to input and output stream in terms of func oning?
(a) File
(c) Reader
(b) Writer
(d) InputStream
24. A stream is a sequence of data.In Java a stream is composed of?
(a) Bits
(b) Bytes
(c) Both A & B
(d) None of the above
25. Which stream does Java applica on uses to read data from a source, it may be a file, an array,
peripheral device or socket?
(a) InputStream
(c) Input/OutputStream
(b) OutputStream
(d) None of the above
26. ObjectFilter is a member of java.io package.
(a) True
(b) False
(c) Can not say
6
(d) Can be true or false
27. returns true false when called on a if called on a file and returns
(a) IsFile()
(b) isFile()
(c) Isfile()
(d) isfile()
28. Which of these class is implemented by FilterInputStream class?
(a) InputStream
(b) FileInputStream
(c) BufferedInputStream
(d) BufferedFileInputStream
29. Which of these class is implemented by FilterInputStream class?
(a) InputStream
(b) InputOutputStream
(c) BufferedInputStream
(d) SequenceInputStream
30. Which of these func ons is called to display the output of
an applet?
(a) paint()
(c) PrintApplet()
(b) display()
(d) display Applet()
31. Which of these methods can be used to output a string in an applet?
(a) display()
(b) print()
(c) drawString()
(d) transient()
7
32. Which of these methods is a part of Abstract Window Toolkit (AWT)?
(a) paint()
(c) transient()
(b) display()
(d) drawString()
33. Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts
of a program?
(a) vola le
(b) global
(c) transient
(d) No modifier is needed
34. An applet is a Java class that extends the
(a) java class
(b) Applet class
(c) java. Applet class
(d) java.applet.Applet class
35. Applets are designed to be embedded within an
(a) SQL
(b) HTML
(c) Css
(d) Javascript
36. Which of these class is used to create an object whose character sequence is mutable?
(a) String()
(b) StringBuffer()
(c) Both of the men oned
(d) None of the men oned
37. Which of these method of class StringBuffer is used to reverse sequence of characters?
8
(a) reverse()
(b) Reverse()
(c) reverseall()
(d) reverseAll()
38. Which of the following statement is correct?
(a) reverse() method reverses all characters.
(b) reverseall() method reverses all characters.
(c) replace() method replaces first occurrence of a character in invoking string with another character.
(d) replace() method replaces last occurrence of a character in invoking string with another character.
39. Which metnod is only called when the browser shuts down normally?
(a) start
(b) stop
(c) paint
(d) destroy
40. The method ....., force writes whenever the data accumulates in the output stream.
(a) write()
(b) flush()
(c) read()
(d) reset()
41. What will be output for the following code?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
public void paint(Graphics g)
{
g.drawString("A Simple Applet"", 20, 20); }
}
(a) A Simple Applet
(b) Compila on Error
(c) A Simple Applet 20 20
(d) Run me Error
9
42. The class provides the capacity to read primi ve data types from an input stream.
(a) PipeInputStream
(b) DataInputStream
(c) pushbackInputStream
(d) BufferedInputStream
43. DataInput is
(a) an abstract class defined in java.io
(b) a class we can use to read primi ve data types
(c) an interface that defines methods to open files
(d) an interface that defines methods to read primi ves data types
44. The class implements the DataInput and DataOutput interfaces for performing I/O using the primi ve
data types.
(a) RandomAccessFile
(b) OutputStream Reader
(c) InputStreamReader
(d) DataOutputStream
45. What is the length of the applica on box made the following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
Graphic g;
g.drawString("A Simple Applet", 20, 20);
(a) 20
(b) Default value
(c) Run me Error
(d) Compila on Error
46. Which of the following would compile without error?
(a) int a Math.abs(-5);
10
(b) int b Math.abs(5.0);
(c) int d Math.abs(5L);
(d) intc Math.abs(5.5F);
47. Which of these classes encapsulate run me state of an object?
(a) Class
(b) System
(c) Run me
(d) Cache
48. Which of these classes is not included in java.lang?
(a) Array
(b) Class
(c) Byte
(d) Integer
49. Which of the following will produce an answer that is closest in value to a double, d, while not being
greater than d?
(a) (int)Math.min(d)
(b) (int)Math.floor(d);
(c) (int)Math.abs(d);
(d) (int)Math.max(d);
50. Which of these methods returns the class of an object?
(a) Class()
(b) getClass()
(c) WhoseClass()
(d) WhoseObject()
51. Waich of these methods return a class object given its name?
(a) getClass()
(b) findClass()
(c) getSystemClass()
11
(d) findSystemClass()
52. Which of these is a process of conver ng a simple data type into a class?
(a) type cas ng
(b) type wrapping
(c) type conversion
(d) none of the Men oned
53. Which of these is a wrapper for data type int?
(a) Integer
(b) Long
(c) Byte
(d) Both a & b
54. All Java classes are derived from
(a) java.awt.Window
(b) java.lang.Object
(c) java.lang.Class
(d) java.u l.Name
55. String class belongs to package
(a) java.awt
(b) java.lang
(c) java.applet
(d) java.string
56. Which of these class have only one field "TYPE"?
(a) Void
(c) System
(b) Process
(d) Run me
57. Which of the following terminate a process? method of Process class can
12
(a) void kill()
(b) void exit()
(c) void destroy()
(d) void terminate()
58. Which of these class defines how the classes are loaded?
(a) Class
(b) System
(c) Run me
(d) ClassLoader
59. Which of these is a super class of wrappers Double & Integer?0000
(a) Digits
(c) Long
(b) Float
(d) Number
60. Which of these is a wrapper for simple data type float?
(a) Float
(b) float
(c) double
(d) Double
61. Which of the following methods is a method of wrapper Integer for obtaining hash code for the
invoking object?
(a) int hash()
(b) int hashcode()
(c) int hashCode()
(d) Integer hashcode()
62. Which of these is wrapper for simple data type char?
(a) Float
(b) String
13
(c) Character
(d) Both b & c
63. Which of the following is method of wrapper Integer for conver ng the value of an object into byte?
(a) Bytevalue()
(b) bytevalue()
(c) Byte Bytevalue()
(d) byte bytevalue()
64. Which of the following is method of wrapper Integer for conver ng the value of an object into int?
(a) Bytevalue()
(b) Bytevalue()
(c) int intValue();
(d) Byte Bytevalue()
65. Which of these methods is used to obtain value of invoking object as a long?
(a) Long value()
(b) Long longValue()
(c) Long longvalue()
(d) Long Longvalue()