adplus-dvertising

Welcome to the Classes and Methods MCQs Page

Dive deep into the fascinating world of Classes and Methods with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Classes and Methods, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Classes and Methods, 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 Classes and Methods. 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 Classes and Methods. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Classes and Methods MCQs | Page 10 of 30

Explore more Topics under Java Programming

Q91.
What would be the output of following snippet, if compiled and executed with command line argument β€œjava abc 1 2 3”?
public class abc
{
   static public void main(String [] xyz)
   {
       for(int n=1;n<xyz.length; n++)
       {
          System.out.println(xyz[n]+"");
       }
   }
}
Discuss
Answer: (b).2 3
Q92.
What is the output of the following snippet running with β€œjava demo I write java code”?
public class demo
{
   public static void main(String args[])
   {
        System.out.println(args[0]+""+args[args.length-1]);
   }
}
Discuss
Answer: (d).The snippet compiles, runs and prints β€œI code”
Q93.
What would be the output of the following snippet, if compiled and executed with command line β€œhello there”?
public class abc
{
String[] xyz;
 
public static void main(String argv[])
{
xyz=argv;
}
 
public void runMethod()
{
System.out.println(argv[1]);
}
}
Discuss
Answer: (a).Compile time error
Discuss
Answer: (a).Arguments tab
Q95.
Which class allows parsing of command line arguments?
Discuss
Answer: (b).JCommander
Q96.
Which annotation is used to represent command line input and assigned to correct data type?
Discuss
Answer: (d).@Parameter
Q97.
What is the output of below snippet run as $ java Demo –length 512 –breadth 2 -h 3 ?
class Demo {
    @Parameter(names={"--length"})
    int length;
 
    @Parameter(names={"--breadth"})
    int breadth;
 
    @Parameter(names={"--height","-h"})
    int height;
 
    public static void main(String args[]) 
    {
        Demo demo = new Demo();
        new JCommander(demo, args);
        demo.run();
    }
 
    public void run() 
    {
        System.out.println(length+" "+ breadth+" "+height);
    }
}
Discuss
Answer: (c).512 2 3
Discuss
Answer: (b).Allows one to put all your options into a file and pass this file as a parameter
Discuss
Answer: (b).Recursion is a process of defining a method that calls other methods repeatedly
Q100.
Which of these data types is used by operating system to manage the Recursion in Java?
Discuss
Answer: (b).Stack

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!