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

Q211.
What will be the output of the program?

try 
{
    Float f1 = new Float("3.0");
    int x = f1.intValue();
    byte b = f1.byteValue();
    double d = f1.doubleValue();
    System.out.println(x + b + d);
}
catch (NumberFormatException e) /* Line 9 */
{
    System.out.println("bad number"); /* Line 11 */
}
Discuss
Answer: (a).9.0
Q212.
What will be the output of the program?

class Q207 
{ 
    public static void main(String[] args) 
    {
        int i1 = 5; 
        int i2 = 6; 
        String s1 = "7"; 
        System.out.println(i1 + i2 + s1); /* Line 8 */
    } 
}
Discuss
Answer: (b).117
Q213.
What will be the output of the program?

public class SqrtExample 
{
    public static void main(String [] args) 
    {
        double value = -9.0;
        System.out.println( Math.sqrt(value));
    }
}
Discuss
Answer: (c).NaN
Q214.
What will be the output of the program?

String s = "ABC"; 
s.toLowerCase(); 
s += "def"; 
System.out.println(s);
Discuss
Answer: (c).ABCdef
Q215.
Which statement is true given the following?

Double d = Math.random();
Discuss
Answer: (b).0.0 <= d < 1.0
Q216.
Which two statements are true about wrapper or String classes?

1. If x and y refer to instances of different wrapper classes, then the fragment x.equals(y) will cause a compiler failure.
2. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true.
3. If x and y are String references and if x.equals(y) is true, then x == y is true.
4. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true.
5. If x and y are String references and x == y is true, then y.equals(x) will be true.
Discuss
Answer: (d).4 and 5
Q217.
Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d?
Discuss
Answer: (d).(int)Math.floor(d);
Q218.
What two statements are true about the result obtained from calling Math.random()?


1. The result is less than 0.0.
2. The result is greater than or equal to 0.0..
3. The result is less than 1.0.
4. The result is greater than 1.0.
5. The result is greater than or equal to 1.0.
Discuss
Answer: (b).2 and 3
Q219.
Which of these class have only one field "TYPE"?
Discuss
Answer: (a).Void
Q220.
Standard output variable "out" is defined in which class?
Discuss
Answer: (d).System

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!