Java IO and Applets Mcqs

Our collections of Multiple choice questions and answers focuses on study of Java IO and Applets . These questions are chosen from a collection of most authoritative and best reference books on Java. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Java IO and Applets topic comprehensively.

4.
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);
        }
    }

Hello

World

Helloworld

Hello World

9.
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') ));
        }
    }

6 4 6 9

5 4 5 9

7 8 8 9

4 3 6 9

10.
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 is a lower case Letter is White space character

b is a lower case Letter is White space characte

a is a lower case Letter A is a upper case Letter

a is a lower case Letter 0 is a digit

11.
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);
        }
    }

Hello

OlleH

HelloolleH

OlleHHello

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

IOException

FileException

FileNotFoundException

FileInputException

0Shares
0
Scroll to Top