TOTAL QS = 14Time [ 00 : 00 : 00 ]
00:00:00

Java Varargs Basics Online Test 1

Instructions

Total Questions: 14

Total Minutes: 14

This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on the basics of Java Varargs or Variable Arguments. This test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics.

Go through Java Theory Notes on Varargs before attempting this test.

All the Best

Challenge SCORE

0 / 14

Take This Exam
1) Java Varargs are applicable only for ___.
2) A Java-Vararg is nothing but ____.
3) A Java vararg is a ____.
4) A Java-Vararg can be of any type like primitive or object type. State TRUE or FALSE.
5) A Java Vararg or Variable Argument can come at any position in a method or constructor. State TRUE or FALSE.
6) 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");
  }
}
7) 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();
  }
}
8) Which is the error thrown when two methods with varargs look the same to the compiler?
9) 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();
  }
}
10) What is the output of the below Java program with Varargs?
public class Varargs4
{
  Varargs4(int... carnums)
  {
    System.out.println("Inside Varargs(int...)");
  }
  Varargs4(float... prices)
  {
    System.out.println("Inside Varargs(float...)");
  }
  public static void main(String[] args)
  {
    new Varargs4();
  }
}
11) What is the output of the below code snippet?
public class Varargs5
{
  Varargs5(int...weights, boolean yesno)
  {
    System.out.println("AMAZON");
  }
  public static void main(String[] args)
  {
   //new Varargs5(20, true);
  }
}
12) Which is the operator used to represent a Vararg type in a method or constructor in Java?
13) How many maximum numbers of Varargs or Variable-Arguments can be there in a method or a constructor in Java?
14) What is the maximum number of methods or constructors with Varargs in a single Java class?

Open Certification Helper Popup Reset Popup