Muhammad Abrar 36602
Muhammad Zeeshan 36578
Java is a programming language that
produces software for multiple
platforms. When a programmer writes a
Java application, the compiled code
(known as bytecode)
Operators in Java
Java provides many types of operators which can be used
according to the need. They are classified based on the
functionality they provide. Some of the types are-
1.Arithmetic Operators
2.Unary Operators
3.Assignment Operator
4.Relational Operators
5.Logical Operators
 In C, almost everything is in functions
 In Java, almost everything is in classes
 There is often only a class per file
 There must be only one public class per file
 The file name must be the same as the
name of that public class, but with a .java
extension
 A typical Java file looks like:
import java.awt.*;
import java.util.*;
public class SomethingOrOther {
// object definitions go here
. . .
}
This must be in a file named SomethingOrOther.java !
class Simple
{
public static void main(String args[])
{
System. out. println("Hello Java");
}
}
import java.util.Scanner;
public class table
{
public static void main(String args[])
{
int n, c;
System.out.println("Enter an integer to print it's multiplication table");
Scanner in = new Scanner(System.in);
n = in.nextInt();
System.out.println("Multiplication table of " + n);
for (c = 1; c <= 10; c++)
System.out.println(n + "*" + c +" = " + (n*c));
}
}
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args){
int year;
System.out.println("Enter an Year :: ");
Scanner sc = new Scanner(System.in);
year = sc.nextInt();
if (year % 4 == 0)
System.out.println("Specified year is a leap year");
else
System.out.println("Specified year is not a leap year");
}
}

Java

  • 1.
  • 2.
    Java is aprogramming language that produces software for multiple platforms. When a programmer writes a Java application, the compiled code (known as bytecode)
  • 7.
    Operators in Java Javaprovides many types of operators which can be used according to the need. They are classified based on the functionality they provide. Some of the types are- 1.Arithmetic Operators 2.Unary Operators 3.Assignment Operator 4.Relational Operators 5.Logical Operators
  • 8.
     In C,almost everything is in functions  In Java, almost everything is in classes  There is often only a class per file  There must be only one public class per file  The file name must be the same as the name of that public class, but with a .java extension
  • 9.
     A typicalJava file looks like: import java.awt.*; import java.util.*; public class SomethingOrOther { // object definitions go here . . . } This must be in a file named SomethingOrOther.java !
  • 12.
    class Simple { public staticvoid main(String args[]) { System. out. println("Hello Java"); } }
  • 13.
    import java.util.Scanner; public classtable { public static void main(String args[]) { int n, c; System.out.println("Enter an integer to print it's multiplication table"); Scanner in = new Scanner(System.in); n = in.nextInt(); System.out.println("Multiplication table of " + n); for (c = 1; c <= 10; c++) System.out.println(n + "*" + c +" = " + (n*c)); } }
  • 14.
    import java.util.Scanner; public classLeapYear { public static void main(String[] args){ int year; System.out.println("Enter an Year :: "); Scanner sc = new Scanner(System.in); year = sc.nextInt(); if (year % 4 == 0) System.out.println("Specified year is a leap year"); else System.out.println("Specified year is not a leap year"); } }