Ticker

6/recent/ticker-posts

Ad Code

L4, Synatx of main method, Understanding Command line arguments, package q10794, q10795 &q10796

Assume that five command line arguments will be passed to the below class with name CommandLineArgumentDemo.


Write code in the main(String[] args) method to print only the fourth argument.

package q10794 :-

package q10794;
public class CommandLineArgumentDemo {
    public static void main(String[] args) {
        //Write the code fragment in the below println(     ) method to print only the
fourth argument
        System.out.println(args[3]);
    }
}


Assume that five command line arguments will be passed to the below class with name CommandLineArgumentDemo.
Write code in the main(String[] args) method to print only the first argument.

package q10795 :-

package q10795;
public class CommandLineArgumentDemo {
    public static void main(String[] args) {
        //Write the code fragment in the below println(     ) method to print only the first argument
        System.out.println(args[0]);
    }
}


Assume that five command line arguments will be passed to the below class with name CommandLineArgumentDemo. Write code in the main(String[] args) method to print only the fifth argument.

package q10796 :-

package q10796;
public class CommandLineArgumentDemo {
    public static void main(String[] args) {
        //Write the code fragment in the below println(     ) method to print only the fifth argument
        System.out.println(args[4]);
    }
}

Post a Comment

0 Comments