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 19 of 26

Q181.
What is the output of this program?
    class newthread implements Runnable 
    {
	Thread t;
        newthread() 
        {
            t = new Thread(this,"My Thread");
            t.start();
	}
	public void run() 
        {
	    System.out.println(t.getName());
	}
    }
    class multithreaded_programing 
    {
        public static void main(String args[]) 
        {
            new newthread();        
        }
    }
Discuss
Answer: (a).My Thread
Q182.
What is the output of this program?
    class newthread implements Runnable 
    {
	Thread t;
        newthread() 
        {
            t = new Thread(this,"My Thread");
            t.start();
	}
	public void run() 
        {
	    System.out.println(t);
	}
    }
    class multithreaded_programing 
    {
        public static void main(String args[]) 
        {
            new newthread();        
        }
    }
Discuss
Answer: (b).Thread[My Thread,5,main].
Q183.
What is the value of "d" after this line of code has been executed?

double d = Math.round ( 2.5 + Math.random() );
Discuss
Answer: (b).3
Q184.
Which of the following would compile without error?
Discuss
Answer: (a).int a = Math.abs(-5);
Q185.
Which of the following are valid calls to Math.max?

1. Math.max(1,4)
2. Math.max(2.3, 5)
3. Math.max(1, 3, 5, 7)
4. Math.max(-1.5, -2.8f)
Discuss
Answer: (a).1, 2 and 4
Q186.

Select how you would start the program to cause it to print: Arg is 2
public class Myfile 
{ 
    public static void main (String[] args) 
    {
        String biz = args[1]; 
        String baz = args[2]; 
        String rip = args[3]; 
        System.out.println("Arg is " + rip); 
    } 
}
Discuss
Answer: (c).java Myfile 1 3 2 2
Q187.
What will be the output of the program?

public class Test 
{ 
    public static void main(String[] args) 
    {
        final StringBuffer a = new StringBuffer(); 
        final StringBuffer b = new StringBuffer(); 

        new Thread() 
        { 
            public void run() 
            {
                System.out.print(a.append("A")); 
                synchronized(b) 
                { 
                    System.out.print(b.append("B")); 
                } 
            } 
        }.start(); 
            
        new Thread() 
        {
            public void run() 
            {
                System.out.print(b.append("C")); 
                synchronized(a) 
                {
                    System.out.print(a.append("D")); 
                } 
            } 
        }.start(); 
    } 
}
Discuss
Answer: (d).Indeterminate output
Q188.
What will be the output of the program?

1. A
2. B
3. C
4. D

String s = "hello"; 
Object o = s; 
if( o.equals(s) )
{
    System.out.println("A"); 
} 
else
{
    System.out.println("B"); 
} 
if( s.equals(o) )
{
    System.out.println("C"); 
} 
else
{ 
    System.out.println("D"); 
}
Discuss
Answer: (a).1 and 3
Q189.
What will be the output of the program (in jdk1.6 or above)?

public class BoolTest 
{
    public static void main(String [] args) 
    {
        Boolean b1 = new Boolean("false");
        boolean b2;
        b2 = b1.booleanValue();
        if (!b2) 
        {
            b2 = true;
            System.out.print("x ");
        }
        if (b1 & b2) /* Line 13 */
        {
            System.out.print("y ");
        }
        System.out.println("z");
    }
}
Discuss
Answer: (b).x z
Q190.
What will be the output of the program?

public class Test138 
{ 
    public static void stringReplace (String text) 
    {
        text = text.replace ('j' , 'c'); /* Line 5 */
    } 
    public static void bufferReplace (StringBuffer text) 
    { 
        text = text.append ("c");  /* Line 9 */
    } 
    public static void main (String args[]) 
    { 
        String textString = new String ("java"); 
        StringBuffer textBuffer = new StringBuffer ("java"); /* Line 14 */
        stringReplace(textString); 
        bufferReplace(textBuffer); 
        System.out.println (textString + textBuffer); 
    } 
}
Discuss
Answer: (c).javajavac

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!