s3bsc_fair_record
s3bsc_fair_record
History of Java
The history of Java starts with the Green Team. Java team members (also known as
Green Team), initiated this project to develop a language for digital devices such as
set-top boxes, televisions, etc. However, it was best suited for internet programming.
Later, Java technology was incorporated by Netscape.
The principles for creating Java programming were "Simple, Robust, Portable,
Platform-independent, Secured, High Performance, Multithreaded, Architecture
Neutral, Object-Oriented, Interpreted, and Dynamic". Java was developed by James
Gosling, who is known as the father of Java, in 1995. James Gosling and his team
members started the project in the early '90s.
Features of Java
The primary objective of Java programming language creation was to make it portable,
simple and secure programming language. Apart from this, there are also some
excellent features which play an important role in the popularity of this language. The
features of Java are also known as Java buzzwords.
A list of the most important features of the Java language is given below.
1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic
Standalone Applications
Applets
Applets are Java programs that are designed to run within web browsers. They were
popular in the early days of the internet and provided a way to add interactive content
to web pages.
Output:
Enter an Year : 2024
Specified year is a leap year
Result : Program has been executed successfully executed and output is obtained.
Result : Program has been executed successfully executed and output is obtained.
3. FIBONACCI SERIES
Aim: Program to print the fibonacci series upto a certain limit
Program:
import java.util.*;
class Series{
public static void main(String args[])
{
int a=0,b = 1,c ,i,n;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the limit : ");
n = sc.nextInt();
System.out.print(a+" "+b);
for(i=2;i<n;++i)
{
c=a+b;
System.out.print(" "+c);
a=b;
b=c;
}
}}
Output:
Enter the limit :
5
01123
Result : Program has been executed successfully executed and output is obtained.
4. PALINDROME
Aim: Program to check whether a number is palindrome or not
Program:
import java.util.*;
class Palindrome{
public static void main(String args[]){
int r,a,s=0,temp;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number : ");
a = sc.nextInt();
temp=a;
while(a>0){
r=a%10;
s=(s*10)+r;
a=a/10;
}
if(temp==s){
System.out.println("Palindrome number ");
}
else{
System.out.println("Not palindrome");
}
}
}
Output:
Enter the number :
151
Palindrome number
Result : Program has been executed successfully executed and output is obtained.
5. ARMSTRONG
Aim: Program to check whether a number is armstrong or not
Program:
import java.util.*;
public class Armstrong
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int temp, n, s=0, r;
System.out.println(“Enter the number : ”);
n = sc.nextInt();
temp = n;
while(n!=0)
{
r = n%10;
s = s + r*r*r;
n=n/10;
}
if(temp == s)
{
System.out.println(“Armstrong number”);
}
else
{
System.out.println(“Not a armstrong number”);
}
}
}
Output:
Enter the number :
153
Armstrong number
Result : Program has been executed successfully executed and output is obtained.
6. SUM OF DIGITS OF A NUMBER
Aim: Program to find sum of digits of a number
Program:
import java.util.*;
class sum
{
public static void main(String args[])
{
int n, d , s = 0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter the number : ”);
n = sc.nextInt();
while(n>0)
{
d = n%10;
s = s+d;
n = n/10;
}
System.out.println(“The sum of digits of number = ”+s);
}
}
Output:
Enter the number :
86
The sum of digits of number = 14
Result : Program has been executed successfully executed and output is obtained.
7. CONSTRUCTOR
Aim: Program to define a class with a constructor and calculate the area of
a rectangle using method
Program:
class Rectangle
{
int length, breadth;
Rectangle(int l, int b)
{
length = l;
breadth = b;
}
void area()
{
int a = l*b;
System.out.println(“The area of rectangle = ” + a);
}
}
class Area
{
public static void main(String args[])
{
Rectangle r = new Rectangle(2, 6);
r.area();
}
}
Output:
The area of rectangle = 12
Result : Program has been executed successfully executed and output is obtained.
8. INHERITANCE
Aim: Program to display progress report of a student using inheritance
Program:
import java.util.*;
class Student
{
int rollno, m1, m2, total;
String name;
void total()
{
total = m1+m2;
}
}
class Report extends Student
{
void display()
{
System.out.println(“Name = ” + name);
System.out.println(“Rollno = ” + rollno);
System.out.println(“Total = ” + total);
}
public static void main(String args[])
{
Report r = new Report();
Scanner sc = new Scanner(System.in);
System.out.println(“Enter Name , Rollno, Mark1, and Mark2 ”);
r.name = sc.nextLine();
r.rollno = sc.nextInt();
r.m1 = sc.nextInt();
r.m2 = sc.nextInt();
r.total();
r.display();
}
}
Output:
Enter Name , Rollno, Mark1, and Mark2
Anandhu
8
24
26
Name = Anandhu
Rollno = 8
Total = 50
Result : Program has been executed successfully executed and output is obtained.
9. METHOD OVERRIDING
Aim: Program to demonstrate method overriding
Program:
class Bank
{
float getRateOfInterest()
{
return 0.0f;
}
}
class SBI extends Bank
{
float getRateOfInterest()
{
return 8.4f;
}
}
class ICICI extends Bank
{
float getRateOfInterest()
{
return 7.3f;
}
}
class AXIS extends Bank
{
float getRateOfInterest()
{
return 9.7f;
}
}
class Main
{
public static void main(String args[])
{
Bank b;
b = new SBI();
System.out.println(“SBI rate of interest : ” + b.getRateOfInterest());
b = new ICICI();
System.out.println(“ ICICI rate of interest : ” +
b.getRateOfInterest());
b = new AXIS();
System.out.println(“ AXIS rate of interest : ” +
b.getRateOfInterest());
}
}
Output:
SBI rate of interest : 8.4
ICICI rate of interest : 7.3
AXIS rate of interest : 9.7
Result : Program has been executed successfully executed and output is obtained.
12. PACKAGE
Aim: Program to find factorial of a number using package
Program:
package p;
public class findfact
{
public void fact(int n)
{
int f = 1;
for(int i = 1; i<=n; i++)
{
f = f*i;
}
System.out.println(“fact = ”+f);
}
}
import p.*;
class demo
{
public static void main(String args[])
{
findfact ob = new findfact();
ob.fact(4);
}
}
Output:
Fact = 24
Result : Program has been executed successfully executed and output is obtained.
14. THREAD
Aim: Program to print odd and even numbers using thread concept
Program:
import java.util.*;
class even extends Thread
{
public void run()
{
int i;
for(i = 1 ; i<=10 ; i++)
{
if(i%2 == 0)
{
System.out.println(“i = ”+i);
}
}
}
}
class Threading
{
public static void main(String args[])
{
try
{
BufferedReader out = new BufferedReader(new FileReader(file));
System.out.println("File content is : ");
while((msg = out.readLine()) != null){
System.out.println(msg);
}
out.close();
}
catch(IOException err)
{
System.out.print("[ERROR] Error occurred : " + err.getMessage());
}
}
}
Output:
Enter text :
Hello world
Contents are added to the file
File closed
File content is :
Hello world
Result : Program has been executed successfully executed and output is obtained.
Output:
Length of HelloWorld is 10
Character at 2nd position = l
Substring from index 3 is loWorld
Concatenated string = HelloWorld
Index of World is 6
Result : Program has been executed successfully executed and output is obtained.
if(e.getSource().equals(bt))
{
c = a + b;
lb3.setText(String.valueOf("Result : "+c));
}
}
public static void main(String args[])
{
new sumAwt();
}
}
Result : Program has been executed successfully executed and output is obtained.