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

Q241.
What is the output of the below Java program?
public class CommandLineArguments3
{
  public static void main(String[] args)
  {
    String name = args[0];
    int age = Integer.parseInt(args[1]);
    Boolean married = Boolean.parseBoolean(args[2]);
    Float salary = Float.parseFloat(args[3]);
    System.out.println("Name="+name + ", Age=" + age + ", Married=" + married + ", Salary=$"+ salary);
  }
}

C:\folder>java CommandLineArguments3 Marker 25 false 5025.35
Discuss
Answer: (a).Name=Marker, Age=25, Married=false, Salary=$5025.35
Q242.
Java Varargs are applicable only for ___.
Discuss
Answer: (c).Both Constructors and Methods
Discuss
Answer: (a).Variable number of arguments
Q244.
A Java vararg is a ____.
Discuss
Answer: (c).Variable
Q245.
A Java-Vararg can be of any type like primitive or object type. State TRUE or FALSE.
Discuss
Answer: (a).TRUE
Q246.
A Java Vararg or Variable Argument can come at any position in a method or constructor. State TRUE or FALSE.
Discuss
Answer: (b).TRUE
Q247.
What is the output of the below java program with varargs?
public class Varargs1
{
  static void displayStudents(String... stu)
  {
    for(String s: stu)
      System.out.print(s + " ");
  }
  public static void main(String args[])
  {
    displayStudents("Bean", "Atkinson", "Milton");
  }
}
Discuss
Answer: (c).Bean Atkinson Milton
Q248.
What is the output of the below Java program with Variable arguments?
public class Varargs2
{
  void attendance(String... allStu)
  {
    System.out.println("Attended: " + allStu.length);
  }
  void attendance(boolean... all)
  {
    System.out.println("Attended: " + all.length);
  }
  public static void main(String args[])
  {
    new Varargs2().attendance();
  }
}
Discuss
Answer: (d).Compiler Error
Q249.
Which is the error thrown when two methods with varargs look the same to the compiler?
Discuss
Answer: (a).The method is ambiguous
Q250.
What is the output of the below Java program with Varargs?
public class Varargs3
{
  Varargs3(int... dates)
  {
    System.out.println("Inside Varargs(int...)");
  }
  Varargs3(boolean... yesno)
  {
    System.out.println("Inside Varargs(float...)");
  }
  public static void main(String[] args)
  {
    new Varargs3();
  }
}
Discuss
Answer: (d).Compiler error

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!