Vidyalelo
Java Programming · all questions

Input Output
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

77

Questions

3/4

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following Java 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');
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java 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!='\'');
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
class output
{
    public static void main(String args[])
    { 
         StringBuffer c = new StringBuffer("Hello");
         System.out.println(c.length());
    }
}

Select an option to see the answer and solution.

Which exception is thrown by read() method?

Select an option to see the answer and solution.

Which of these is used to read a string from the input stream?

Select an option to see the answer and solution.

Which of these class is used to read characters and strings in Java from console?

Select an option to see the answer and solution.

Which of these class is implemented by FilterInputStream class?

Select an option to see the answer and solution.

What will be the output of the following Java 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"));
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java 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);
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
class output
{
    public static void main(String args[])
    { 
       StringBuffer s1 = new StringBuffer("Hello");
       s1.setCharAt(1,x);
       System.out.println(s1);
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java 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 != '\'');
    }
}

Select an option to see the answer and solution.

Which of these class contains the methods print() & println()?

Select an option to see the answer and solution.

Which of these methods can be used to writing console output?

Select an option to see the answer and solution.

Which of these classes are used by character streams output operations?

Select an option to see the answer and solution.

Which of these class is used to read from a file?

Select an option to see the answer and solution.

What will be the output of the following Java 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') ));
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java 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;
        }
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
class output
{
    public static void main(String args[])
    { 
       StringBuffer s1 = new StringBuffer("Hello");
       StringBuffer s2 = s1.reverse();
       System.out.println(s2);
    }
}

Select an option to see the answer and solution.

Which of these class contains the methods used to write in a file?

Select an option to see the answer and solution.

Which of these exception is thrown in cases when the file specified for writing is not found?

Select an option to see the answer and solution.