2. what is the meaning of true object
oriented
If we want to do anything in java must be
within a class
3. what is the meaning of
program compilation
Compilation means to convert your actual
programme or source code in to the
machine code or byte code
Machine code machine independent
Run or execute on any operating system
or plat forms is called as platform
independent this is a feature of java
4. what is public static void
main(String x[])
This is the main function of java same like
as main function in c
Static content can share all members in
application so main is available in whole
application
Static content load in memory very first
when program run. for program execution
main method must be load in memory so
main is static
5. what is String x[]
This is a command line argument in java
If we pass the any parameter to main
function is called as command line
argument
what is the use of command line argument in
java
To provide the run time input
7. How to cross check byte code
created or not
After the program compile java create
the one new file automatically is called
as .class file and in this file contain byte
code
Use the command line argument
8. If you want provide the input at run
time
Use the command line argument
Or
Java provide the some inbuilt classes for
input. Command line argument is infinite
string array means we can pass the n
number of input through the command line
argument but the first input start with
zero index(basic array rule)
9. type casting
how to perform the type casting or
type conversion in java
for that java provide some inbuilt classes
for conversion is called as wrapper classes
syntax -->
integervariable=Integer.parseInt(value for conversion|);
e.g. a=Integer.parseInt(x[0]);
10. Integer is a class in java and parseInt() is
the static method of Integer class this
method is used to convert the any value.
floatvriable=Float.parseFloat(value);
or
Float.valueOf(value).floatValue();
11. public class FirstBatch{
public static void main(String x[])
{ int a,b,c;
a=Integer.parseInt(x[0]);
b=Integer.parseInt(x[1]);
c=a+b;
System.out.println("Addition is "+c);
}
}
12. DataInputStream
This class is used to accept the input
from keyboard same like as scanf() in c
this class is a member of java.io package
To add follow some step’s
Add java.io. pacakge in programme
package is a collection of classes same like
as header file in c
header file is a collection of functions in c
13. import packagename;
e.g. import java.io.*; -->this statement
allow us to use all classes present in
java.io.
import java.io.DataInputStream;-->we can
use only one class in program from java.io
package
import is the keyword in java which is used
to add the package in program
14. create the object of DataInputStream
class
if we want to use the class and its
member any where for that we need to
object
Synatx
DataInputStream objectname=new DataInputStream(System.in);
16. use its readLine() method for input
readLine() is the method of
DataInputStream class which is used to
accept the input from keyboard
Use of readLine() method
objectofdatainputstream.readLine()
17. //P1 import java.io.*;
public class DataFirst
{
public static void main(String x[])throws
Exception
{
DataInputStream xyz=new DataInputStream(System.in);
int num,sq;
System.out.println("Enter the number");
19. //P2
import java.io.*;
public class Student
{
public static void main(String x[])throws Exception
{
DataInputStream input=new DataInputStream(System.in);
int number;
String name;
float marks;
System.out.println("enter the name of student");
name=input.readLine();
System.out.println("Enter the id of student");
number=Integer.parseInt(input.readLine());
System.out.println("Enter the marks of student");
}
21. Problem with readLine() method
Need to convert for every input other than
string for that java provide the another
optional class for input to us Scanner .
22. Scanner is a class same like as
DataInputStram Scanner is a member of
java.util package
add the util package in programme
import java.util.*;
create the object of Scanner class
Scanner object=new Scanner(System.in);
e.g Scanner input=new Scanner(System.in);
Use its following method for input
23. nextInt() --> for integer input
nextFloat() ---> for float input
nextDouble() --> for double input
nextByte() --> for byte input
nextLine() ----> for string input
nextShort() -->short integer input
nextLong() ---> for long integer input
24. import java.util.*;
public class ScannerApp
{
public static void main(String x[])
{
Scanner xyz=new Scanner(System.in);
int id;
float marks;
String name;
System.out.println("Enter the name ");
name=xyz.nextLine();
System.out.println("enter the id ");
id=xyz.nextInt();
System.out.println("enter the marks ");