You are on page 1of 17

Basic I/O

Which of these data types is used to store command line arguments?

a. Array
b. Stack
c. String
d. Integer
Basic I/O
class Test
{
public static void main(String[] args)
{
for(int i = 0; 1; i++) Output: Error
{
System.out.println("Hello");
break;
}
}
}
Basic I/O
Can command line arguments be converted into int automatically if required?

a. Yes

b. No

c. Compiler dependent
d. Only ASCII can be converted
Basic I/O
Which is the correct declaration of a boolean variable?

a. boolean check=‘false’;

b. boolean check=0;

c. boolean check=“false”
d. boolean check=false
Basic I/O

Write a program to get a input from user and print it using command
line arguments
Basic I/O
What is the output of this program, Command line execution is done
as “java output This is a command Line”?

class Output
{
public static void main(String args[])
{ Output: This
System.out.print(args[0]);
}
}
Basic I/O
What is the output of this program, Command line execution is done
as “java output This is a command Line”?

class Output
{
public static void main(String args[])
{ Output: command
System.out.print(args[3]);
}
}
Basic I/O
What is the output of this program, Command line execution is done
as “java output This is a command Line”?

class Output
{
public static void main(String args[])
{ Output:
System.out.print(args);
java.lang.String;@3c679bde
}
}
Basic I/O

Write a program to get a input from user add 2 numbers and print the
result using command line arguments
Basic I/O
What is the output of this program

public class prg a. -1


{
public static void main(String[] args) b. 255
{
System.out.println( (byte) 0xff);
}
c. 65535
}
d. 0xff
Basic I/O
What are scanners in Java programming language?

It enables splitting of string and primitive data into separate tokens,


based on a delimiter that can be a regular expression
Basic I/O

Write a program to get a input from user and swap 2 numbers using
command line arguments
Basic I/O

Write a program to get a input from user and swap 2 numbers without
using third variable using command line arguments
Basic I/O
What are the I/O streams Java programming language?

Input sources from which data is read, and output destinations to


which data is written

Streams support different kinds of data including bytes, characters,


primitive types and objects
Basic I/O
What should be the name of java program file containing this
program?
a. MyPrg.class
class MyPrg
{
b. MyPrg.java
public static void main(String args[])
{
System.out.print("IncludeHelp"); c. MyPrg
}
} d. Any file name
with java extension
Basic I/O
What should be the name of java program file containing this
program?
a. MyPrg.class
public class MyPrg
{
b. MyPrg.java
public static void main(String args[])
{
System.out.print("IncludeHelp"); c. MyPrg
}
} d. Any file name
with java extension
Basic I/O
What is the output of this program

public class Prg a. ABA


{
public static void main(String args[])
b. AB65
{
System.out.print("A" + "B" + 'A');
} c. error
}
d. AB

You might also like