Influencing policy (training slides from Fast Track Impact)
understanding of java basics
1. OOP - JAVA
Understanding of Java basic concepts
10/23/2021 1
Department of Computer
PRO – GRADE 5
Lecturer. OMEED M. M
Lecture 3
2. Contents
❖ What is NetBeans IDE, and how does it is work?
❖ Understanding of Java program structure
❖ Running first program in java
❖ Some Examples in java
10/23/2021 2
3. NetBeans IDE
NetBeans IDE is a free and open source integrated development environment for
application development on Windows, Mac, Linux, and Solaris operating systems.
The IDE simplifies the development of web, enterprise, desktop, and mobile
applications that use the Java and HTML5 platforms.
10/23/2021 3
5. Running first program in java
/* This is a simple Java program.
FileName : "HelloWorld.java". */
public class HelloWorld {
//Your program begins by calling the main().
//Prints "Hello, World" to the terminal window.
public static void main(String args[]) {
System.out.println("Hello World");
}
}
10/23/2021 5
7. Three primary components of every program in java
1. Class definition: We use the ‘class’ keyword to declare a new class.
We can also use the access specifier like public before the class
keyword:
public class HelloWorld
2. Hello World is the name of the class that is an identifier in Java. The
class definition contains the members of the class that are enclosed
within the curly braces{}.
3. Java Main() method: Every application in Java programming
language must contain a main() method whose signature is:
public static void main(String[] args)
10/23/2021 7
8. public static void main(String[] args)
public: We declare the main method as public so that JVM can execute it from
anywhere.
static: We declare the main method as static so that JVM can call it directly
without creating the object of the class.
Note: We can write the modifiers public and static in any order.
void: The main method does not return anything, therefore we declare it as void.
main(): main() is the name that is already configured in the JVM.
String[]: The main() method accepts a single argument which is an array of
elements of type String
10/23/2021 8
9. Example 1
public class JavaApplication3 {
public static void main(String[] args) {
String FirstName = "Your First name";
String SecondName = "Your Second name";
int age = 22;
int YOB = 1998;
System.out.println(FirstName+"n"+SecondName+"n"+age+"n"+
YOB);
}
}
10/23/2021 9
Write a java program to show your personal detail on the screen (first
name, last name, age, and year of birth)
10. Example 2
Write a java program to show student grade and department (full
name, name of institute, grade, Gender and specialty)
OUTPUT
10/23/2021 10
Your Full name
Da Vinci Institute
PRO 5A
Male or Fe-male
11. Example 3
Write a java program to show Sum of two numbers
10/23/2021 11
public static void main(String []args){
int num1 = 6;
int num2 = 3;
double num3 = 3.2;
double sum;
sum = num1+num2+num3;
System.out.println(sum);
}
}
12. Example 4
Write a java program to check Even or Odd number
10/23/2021 12
public class EvenOddnumber{
public static void main(String []args){
int num = 7;
if ( num % 2 == 0 )
System.out.println(" number is even");
else
System.out.println(" number is odd");
}
}