upload task to the link
link : --> https://forms.gle/vcyYv5RPTd23Vf3y5
https://www.youtube.com/amolujagare
Imp things for the workshop
1. Join whatsapp group - mail to amol@scriptinglogic.net
2. Provide Gmail
Check jdk version : java -version ( on command prompt)
Jdk 17
https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html
Download and install jdk →
Setup the environment variables
Download and install eclipse
https://www.eclipse.org/downloads/
Intellij idea
https://www.jetbrains.com/idea/download
Programming → language
Java → grammar → rules
1. Every program has a starting point
Here it is the main function
public static void main(String[] args)
{
// statements
2. the main function is always written inside a class
class ClassName
{
public static void main(String[] args)
{
// statements
}
}
Write a program to print “hello world”
class HelloWord
{
public static void main(String[] args)
{
System.out.println(“Hello World”);
}
Save the file using className.java (HelloWorld.java)
Reach to the directory where your programs are stored
1. Compile
Javac fileName.java
2. Run
Java className
Before we compile reach to the directory on the command prompt
a , b, c , x , y , z
a= 10 , b =20 , c = 90.56
c= a+ b;
c= 10 + 20 = 30
int a=10;
float c1= 56.78f;
double c2= 56.78;
Numeric Data Types:
● byte:
● Size: 8 bits
● Range: -128 to 127
● short:
● Size: 16 bits
● Range: -32,768 to 32,767
● int:
● Size: 32 bits
● Range: -2,147,483,648 to 2,147,483,647
● long:
● Size: 64 bits
● Range: -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
● float:
● Size: 32 bits
● Range: Approximately ±3.40282347E+38F (6-7 decimal digits)
● double:
● Size: 64 bits
● Range: Approximately ±1.79769313486231570E+308 (15-16
decimal digits)
Character Data Type:
● char:
● Size: 16 bits
● Range: 0 to 65,535 (Unicode characters)
Boolean Data Type:
● boolean:
● Size: Not precisely defined (usually 1 bit)
● Values: true or false
X = 10
Y+z+x=a
y= 11
Z =34
Integer
int a = 89;
d
Decimal
double d = 34.5;
Program 2 → Addition of 2 numbers
a = 10; → complete number → integers → int a;
b = 20 ;
c;
c =a+b;
Integer → whole number → 10
Decimal → 1.2
Datatype
int , double
class Addition
{
public static void main(String[] args)
{
int a=10;
int b=20;
int c;
c = a+b;
System.out.println(c);
}
}
rules to create a class name
1. Use meaning full name
2. Start with capital letter
3. Use camel case (the first letter of the next word should be capital e.g.
AdditionDecimal )
amol@scriptinglogic.net
class
- Collection of data members and member functions
- Data member
int a, double d, char c, String str;
- Member function (or method)
- void functionName()
{
// body
}
- We can not access the data members or member function, inside the
main function directly
- To access the data members or member function we need to create
the object of the class
- Note: Member functions can access the data members directly
Below is the syntax to create an object
ClassName ob = new ClassName();
MyClass
ClassName className = new ClassName();
public class MyClass {
int a;
double d;
char c;
String str;
void display()
{
System.out.println("a="+a);
System.out.println("d="+d);
System.out.println("c="+c);
System.out.println("str="+str);
}
public static void main(String[] args) {
int x;
x = 10 ;
MyClass ob = new MyClass();
ob.a = 10;
ob.d = 90;
ob.c = 'g';
ob.str = "amol";
ob.display();
}
The object is the instance of a class
Each object when created, it allocates a separate memory for each
member
Constructor:
- It is used to initialise the object
- It has the same name as the class name
- It is a method with no return type (like void)
when there is no constructor defined inside the class then the default
constructor is invoked and it initializes the object
When you write a constructor with no ‘body’ inside it, it does the same
effect as that of the default constructor, and it is called an empty
constructor
Today's Task
a. Given length and breadth find the area of rectangle (length x breadth)
b. Given r - radius of circle find the area of circle
link : --> https://forms.gle/vcyYv5RPTd23Vf3y5
Submit before 11 PM tonight
Subscribe to
http://youtube.com/amolujagare
Java sessions (old version - best for concepts )
https://www.youtube.com/watch?v=9UbQA9KT9Ts&list=PLTBsF5WLNKWFa4ANGtbKSOfhNRx
4dOj7V
Queries : amol@scriptinglogic.net