adplus-dvertising

Welcome to the java lang and java io MCQs Page

Dive deep into the fascinating world of java lang and java io with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of java lang and java io, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of java lang and java io, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through java lang and java io. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of java lang and java io. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

java lang and java io MCQs | Page 17 of 26

Q161.
What is the output of this program?
    class Output 
    {
        public static void main(String args[]) 
        {
            byte a[] = { 65, 66, 67, 68, 69, 70 };
            byte b[] = { 71, 72, 73, 74, 75, 76 };  
            System.arraycopy(a, 2, b, 1, a.length-2);
            System.out.print(new String(a) + " " + new String(b));
        }
    }
Discuss
Answer: (b).ABCDEF GCDEFL
Q162.
What is the output of this program?
    class Output 
    {
        public static void main(String args[]) 
        {
            byte a[] = { 65, 66, 67, 68, 69, 70 };
            byte b[] = { 71, 72, 73, 74, 75, 76 };  
            System.arraycopy(a, 1, b, 3, 0);
            System.out.print(new String(a) + " " + new String(b));
        }
    }
Discuss
Answer: (a).ABCDEF GHIJKL
Q163.
What is the output of this program?
    import java.lang.System;
    class Output 
    {
        public static void main(String args[])
        {
            byte a[] = { 65, 66, 67, 68, 69, 70 };
            byte b[] = { 71, 72, 73, 74, 75, 76 };  
            System.arraycopy(a, 0, b, 3, a.length - 3);
            System.out.print(new String(a) + " " + new String(b));
        }
    }
Discuss
Answer: (c).ABCDEF GHIABC
Q164.
What is the output of this program?
    import java.lang.System;
    class Output
    {
        public static void main(String args[])
        {
            byte a[] = { 65, 66, 67, 68, 69, 70 };
            byte b[] = { 71, 72, 73, 74, 75, 76 };  
            System.arraycopy(a, 2, b, 3, a.length - 4);
            System.out.print(new String(a) + " " + new String(b));
        }
    }
Discuss
Answer: (d).ABCDEF GHICDL
Q165.
What value will this program return to Java run-time system?
    import java.lang.System;
    class Output 
    {
        public static void main(String args[])
        {
            System.exit(5);
        }
    }

a.

0

b.

1

c.

4

d.

5

Discuss
Answer: (d).5
Q166.
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)); 
            	   }
               }
           }
        }
    }
Discuss
Answer: (b).ABC
Q167.
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);
           }
        }
    }
Discuss
Answer: (d).AaBaaCaaa
Q168.
What is the output of this program?
    class exception_handling 
    {
            static void throwexception() throws ArithmeticException 
            {        
                System.out.print("0");
                throw new ArithmeticException ("Exception");
            }
            public static void main(String args[]) 
            {
            try 
            {
                throwexception();
            }
            catch (ArithmeticException e) 
            {
                    System.out.println("A");
            }
        }
    }
Discuss
Answer: (c).0A
Q169.
What is the output of this program?
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
             {
                int a = 1;
                int b = 10 / a;
                try 
                {
                     if (a == 1)
                         a = a / a - a;
                     if (a == 2) 
                     {
                         int c[] = {1};
                         c[8] = 9;
                     }
                finally 
                {
                    System.out.print("A");
                }
 
            }
            catch (NullPointerException e) 
            {
                    System.out.println("B");
            }
        }
    }
Discuss
Answer: (a).A
Q170.
What is the output of this program?
Note: Execution command line: $ java exception_handling one two
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                int a = args.length;
                int b = 10 / a;
                System.out.print(a);
                try 
                {
                     if (a == 1)
                         a = a / a - a;
                     if (a == 2) 
                     {
                         int c = {1};
                         c[8] = 9;
                     }
                }
                catch (ArrayIndexOutOfBoundException e) 
                {
                    System.out.println("TypeA");
                }
                catch (ArithmeticException e) 
                {
                    System.out.println("TypeB");
                }
        }
    }
Discuss
Answer: (d).0TypeB

Suggested Topics

Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!