Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Introducing java for a beginner

Rating
-
Sold
-
Pages
54
Uploaded on
07-09-2025
Written in
2025/2026

Giving a 100% introduction programs for a beginner who is willing to study or learn java

Institution
Course

Content preview

JAVA PROGRAMMING CS407

CHAPTER-1

INTRO TO JAVA

1. Write a java program to implement types of variables in java programming

THEORY:

VARIABLE is nothing but a container or name given to a particular memory location.
Variable declaration is very simple. Simply use the data type name and variable name. If you
want to initialize the values then use “=” and assign the values. In java we are having 3 types of
variables

1. Local variable: the variables whose scope is within a method/at particular spot

2. Instance variable: the variables which are executed under a class using objects

3. Static variable: the variables whose scope is throughout the program and there is no need of
object to initialize it

PROGRAM:

class variable

{

public static int num1=123;

public static int num2=62; //static variable

int x,y; //instance variable

void method()

{

int a=46;

int b=45; //local variables

int c=a-b;

System.out.println("local:"+c);

}

int show(int x,int y)


PAGE NAME: G. Sharanya
NO: PIN:23001-CS-061

, JAVA PROGRAMMING CS407

{

return(x+y);

}

int display(int num1,int num2)

{

return(num1-num2);

}

public static void main(String ar[])

{

variable obj=new variable();

obj.method();

System.out.println("instance:"+obj.show(61,22));

System.out.println("static:"+obj.display(num1,num2));

System.out.println("DONE BY SHARANYA");

System.out.println("PIN:23001-CS-061");

}

} //END OF THE PROGRAM

OUTPUT:




PAGE NAME: G. Sharanya
NO: PIN:23001-CS-061

, JAVA PROGRAMMING CS407

2. Write a java program to implement types of data types available in java

THEORY:

“DATA TYPES” are the things which will specify how a variable will is initialized that is how much
storage it takes and what type of data it holds. In java we are having 2 types of data types

1. Primitive data types
2. Non-primitive data types

PRIMITIVE DATA TYPES:

 Integer:
1. Byte : byte stores or allows you to store value between range of -128 to 127
2. Short : short allows you to store values between -32,768 to 32,767
3. Int : int allows you to store values between -2,147,483,648 to 2,147,483,647
4. Long : it is used to store a very large number
 Float:
1. Float: it stores a values with precision that means it used represent decimal numbers
with 8bit precision
2. Double: it stores a values with higher precision that is 16 bits
 Char: it is used to store a character
 String: it is the unique data type in java, which will allow you to store a collection of
characters
 Boolean:it is has only two states 1.ture(1) 2.false (0)

Syntax: datatype variable_name=values;

PROGRAM:

class datatypes

{

public static void main(String ar[])

{

String a="SHARANYA";

String fn="Ganesh";

String fm="rani";

byte pin=061;

int marks=999;


PAGE NAME: G. Sharanya
NO: PIN:23001-CS-061

, JAVA PROGRAMMING CS407

short age=16;

long dadsalary=100000000;

float percentage=99.9f;

double cgpa=99999999.999009;

boolean girl=true;

char yesno='s';

System.out.println("student name:"+a);

System.out.println("student father name:"+fn);

System.out.println("student mother name:"+fm);

System.out.println("student pin:"+pin);

System.out.println("student marks:"+marks);

System.out.println("student percentage:"+percentage);

System.out.println("student cgpa:"+cgpa);

System.out.println("student age:"+age);

System.out.println("student parents salary:"+dadsalary);

System.out.println("student is a good mannered person?"+girl);

System.out.println("student is qualified?"+yesno);

}

}




PAGE NAME: G. Sharanya
NO: PIN:23001-CS-061

Written for

Institution
Course

Document information

Uploaded on
September 7, 2025
Number of pages
54
Written in
2025/2026
Type
Class notes
Professor(s)
Madhavi
Contains
All classes

Subjects

$13.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
sriharshithamamidi

Get to know the seller

Seller avatar
sriharshithamamidi
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
7 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions