0% found this document useful (0 votes)
5 views2 pages

Java Class

The document contains Java code snippets demonstrating the use of the Scanner class for input and variable declarations of different data types. It includes examples of type conversions and static vs. instance variables. There are also syntax errors present in the code that need correction for proper execution.

Uploaded by

Rishabh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Java Class

The document contains Java code snippets demonstrating the use of the Scanner class for input and variable declarations of different data types. It includes examples of type conversions and static vs. instance variables. There are also syntax errors present in the code that need correction for proper execution.

Uploaded by

Rishabh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

*;
//import java.until.scanner;
class Test
{
public static void main(String a[])
{
Scanner sc=new Scanner (System.in);
int a=sc.nextint();
system.out.println(a);
}
}

1.byte a=sc.nextByte();
2.short b=sc.next Short();
3.int c=sc.nextInt();
4.long d=sc.nextLong();
5.string e=sc.next();
6.string f=sc.nextline();
7.float g=sc.nextFloat();
8.double h=sc.nextDouble();
9.boolean i=sc.nextBooolean();

byte+byte=int
byte+shoet=int
int+int=int
int+long=long
l+f=f
f+d=f

byte a=10,b=20,c;
c=byte (a+b);

#code 1
class Test
{
int a=10;
void display()
{
System.out.println(a);
}
public static void main(String arg[])
{
test t=new Test();
System.out.println(t.a);
t.display();

#static
class Test
{
int a=10;
static int b=10
void display()
{
System.out.println(a);
}
public static void main(String arg[])
{
test t=new Test();
System.out.println(t.a);
t.display();

class Test
{
Scanner sc =new Scanner(System.in);

int rollno;
String name;
void get
}

You might also like