JAVA-I/O

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is the output of this program if input given is "abc'def/'egh"? class Input_Output { public static void main(String args[]) throws IOException { char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { c = (char) obj.read(); System.out.print(c); } while(c != '\''); } } a) abc' b) abcdef/' c) abc'def/'egh d) abcqfghq

a

What is the output of this program if input given is "abc'def/'egh"? class Input_Output { public static void main(String args[]) throws IOException { char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { c = (char) obj.read(); System.out.print(c); } while(c!='\''); } } a) abc' b) abcdef/' c) abc'def/'egh d) abcqfghq

a

What is the output of this program? class output { public static void main(String args[]) { String a="hello i love java"; System.out.println(indexof('i')+" "+indexof('o')+" "+lastIndexof('i')+" "+lastIndexof('o') )); } } a) 6 4 6 9 b) 5 4 5 9 c) 7 8 8 9 d) 4 3 6 9

a

What is the output of this program? class output { public static void main(String args[]) { char c[]={'a','1','b',' ','A','0']; for (int i = 0; i < 5; ++i) { if(Character.isDigit(c[i])) System.out.println(c[i]" is a digit"); if(Character.isWhitespace(c[i])) System.out.println(c[i]" is a Whitespace character"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is an Upper case Letter"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is a lower case Letter"); i = i + 3; } } } a) a is a lower case Letter is White space character b) b is a lower case Letter is White space characte c) a is a lower case Letter A is a upper case Letter d) a is a lower case Letter 0 is a digit

a

What is the output of this program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdef"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 0, 3); int i; try { while((i = input2.read()) != -1) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } } a) abc b) abcd c) abcde d) abcdef

a

Which exception is thrown by read() method? a) IOException b) InterruptedException c) SystemException d) SystemInputException

a

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.

a

Which of these class is implemented by FilterInputStream class? a) InputStream b) InputOutputStream c) BufferedInputStream d) SequenceInputStream

a

Which of these class is used to read characters and strings in Java from console? a) BufferedReader b) StringReader c) BufferedStreamReader d) InputStreamReader

a

Which of these classes are used by Byte streams for input and output operation? a) InputStream b) InputOutputStream c) Reader d) All of the mentioned

a

Which of these exception is thrown by close() and read() methods? a) IOException b) FileException c) FileNotFoundException d) FileInputOutputException

a

Which of these is used to perform all input & output operations in Java? a) streams b) Variables c) classes d) Methods

a

Which of these method of class StringBuffer is used to reverse sequence of characters? a) reverse() b) reverseall() c) Reverse() d) reverseAll()

a

What is the output of this program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); System.out.println(c.length()); } } a) 4 b) 5 c) 6 d) 7

b

What is the output of this program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } } a) Hello b) olleH c) HelloolleH d) olleHHello

b

Which of these class contains the methods used to write in a file? a) FileStream b) FileInputStream c) BUfferedOutputStream d) FileBufferStream

b

Which of these class is used to create an object whose character sequence is mutable? a) String() b) StringBuffer() c) Both of the mentioned d) None of the mentioned

b

Which of these classes are used by character streams for input and output operations? a) InputStream b) Writer c) ReadStream d) InputOutputStream

b

Which of these classes are used by character streams output operations? a) InputStream b) Writer c) ReadStream d) InputOutputStream

b

Which of these methods are used to read in from file? a) get() b) read() c) scan() d) readFileInput()

b

What does AWT stands for? a) All Window Tools b) All Writing Tools c) Abstract Window Toolkit d) Abstract Writing Toolkit

c

What is the output of this program if input given is 'abcqfghqbcd'? class Input_Output { public static void main(String args[]) throws IOException { char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { c = (char) obj.read(); System.out.print(c); } while(c != 'q'); } } a) abcqfgh b) abc c) abcq d) abcqfghq

c

What is the output of this program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1,x); System.out.println(s1); } } a) xello b) xxxxx c) Hxllo d) Hexlo

c

What is the output of this program? import java.io.*; class filesinputoutput { public static void main(String args[]) { InputStream obj = new FileInputStream("inputoutput.java"); System.out.print(obj.available()); } } Note: inputoutput.java is stored in the disk. a) true b) false c) prints number of bytes in file d) prints number of characters in the file

c

Which of these class is used to read from a file? a) InputStream b) BufferedInputStream c) FileInputStream d) BufferedFileInputStream

c

Which of these exception is thrown in cases when the file specified for writing it not found? a) IOException b) FileException c) FileNotFoundException d) FileInputException

c

Which of these is a type of stream in Java? a) Integer stream b) Short stream c) Byte stream d) Long stream

c

Which of these methods is used to write() into a file? a) put() b) putFile() c) write() d) writeFile()

c

Which of these values is returned by read() method is end of file (EOF) is encountered? a) 0 b) 1 c) -1 d) Null

c

What is the output of this program if input given is "Hello stop World"? class Input_Output { public static void main(String args[]) throws IOException { string str; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { str = (char) obj.readLine(); System.out.print(str); } while(!str.equals("strong")); } } a) Hello b) Hello stop c) World d) Hello stop World

d

What is the output of this program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello World"); s1.insert(6 , "Good "); System.out.println(s1); } } a) HelloGoodWorld b) HellGoodoWorld c) HellGood oWorld d) Hello Good World

d

What is the output of this program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); StringBuffer c1 = new StringBuffer(" World"); c.append(c1); System.out.println(c); } } a) Hello b) World c) Helloworld d) Hello World

d

What is the output of this program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdefgh"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 1, 4); int i; int j; try { while((i = input1.read()) == (j = input2.read())) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } } a) abc b) abcd c) abcde d) None of the mentioned

d

What is the output of this program? import java.io.*; public class filesinputoutput { public static void main(String[] args) { String obj = "abc"; byte b[] = obj.getBytes(); ByteArrayInputStream obj1 = new ByteArrayInputStream(b); for (int i = 0; i < 2; ++ i) { int c; while((c = obj1.read()) != -1) { if(i == 0) { System.out.print(Character.toUpperCase((char)c)); obj2.write(1); } } System.out.print(obj2); } } } a) AaBaCa b) ABCaaa c) AaaBaaCaa d) AaBaaCaaa

d

Which of these class contains the methods print() & println()? a) System b) System.out c) BUfferedOutputStream d) PrintStream

d

Which of these class is used to read from byte array? a) InputStream. b) BufferedInputStream. c) ArrayInputStream. d) ByteArrayInputStream.

d

Which of these is used to read a string from the input stream? a) get() b) getLine() c) read() d) readLine()

d

Which of these methods can be used to writing console output? a) print() b) println() c) write() d) All of the mentioned

d


Kaugnay na mga set ng pag-aaral

Nursing Management of Pregnancy at Risk: Pregnancy-Related Complications

View Set

Chapter 1 - Electronic Health Record Key Terms (MA 171)

View Set

BIO 211 Midland's Tech Koziel Test 4

View Set

A&P Final Exam- Review Questions

View Set

Pharmacology Chapter 43: Diuretics

View Set

Accounting Chp 3- Cost-Volume-Profit Analysis and Pricing Decisions

View Set