Basic Features of java |
What is Java?
Java is an object-oriented programming language built by James Gosling and his colleagues at Sun MicroSystems. Now Java is maintained by Oracle Corporation. Oak was the first name of Java. It was designed to have the "look and feel" of the C++ language, but it is simpler to use than C++ and enforces an object-oriented programming model.
What are the Basic Features of java?
What are the advantages of OOP?
Java is an object-oriented language.
Java is Easy to write and more readable and eye-catching.
Java program cannot harm other systems thus making it
secure.
Java programs can be run on any platform (Linux, Window,
Mac)
Java program both compiled and interpreted
Java provides integrated support for multithreaded
programming.It can handle many tasks simultaneously.
Java was designed with a distributed environment.
Java has a strong memory allocation and automatic garbage collection
mechanism.
Java uses 16-bit Unicode, instead of 8-bit ASCII code.
What are the advantages of OOP?
Easy to relate to the real world.
Data is protected from misuse.
All data is hidden only the method is visible.
We can reuse the code with the help of the Inheritance concept.
Secured
Easy to maintain
What are the Basic components of OOP?
1. Class—It is a blueprint of an object.
2. Object—An instance of a class or It is a template of a class.
3. Encapsulation—The wrapping up of data and method into a single unit called Encapsulation.
4. Abstraction—It is the act of representing essential features without including the background details.
5. Polymorphism -- polymorphism refers to a programming language's ability to process objects differently depending on their data type or class.
6. Inheritance -- Inheritance is the process by which objects of one class acquire the properties of objects of another class.
What are the types of Java applications?
Basically, Java Applications can be 4 types
1) Standalone application core java
2) Client-Server application core java and web technology
3) Web Application Servlet, JSP, Struts, Hibernate, etc.
4) Distributed Application EJB application
What is UNICODE?
It is a two bytes character code that is used for internal representation of characters. It is a 16-bits code. Unicode is maintained by the Unicode® Consortium.
Simple Java Programs
// Summation of two numbers in java
import java.io.*;public class Summation
{
public static void main()throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(in);
int a,b,c;
System.out.println("Enter two number:");
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
c=a+b;
System.out.println(c);
}
}
//Addition and Average of student Marks
import java.util.Scanner;
public class Student
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int m1,m2,m3,tot,avg;
String name;
System.out.println("Enter three subjects marks:");
m1=sc.nextInt();
m2=sc.nextInt();
m3=sc.nextInt();
System.out.println("Enter Student name:");
name=sc.next();
tot=m1+m2+m3;
avg=tot/3;
System.out.println(name+" Total="+tot+" Average="+avg);
}
}
public class Student
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int m1,m2,m3,tot,avg;
String name;
System.out.println("Enter three subjects marks:");
m1=sc.nextInt();
m2=sc.nextInt();
m3=sc.nextInt();
System.out.println("Enter Student name:");
name=sc.next();
tot=m1+m2+m3;
avg=tot/3;
System.out.println(name+" Total="+tot+" Average="+avg);
}
}
//Java Program to Convert Fahrenheit into Celsius
import java.util.*;
public class TemperatureCoversion
{
public static void main(String args[])
{
Scanner a=new Scanner(System.in);
System.out.println("Enter Your Choice");
System.out.println("Enter 1 for conversion to celsius");
System.out.println("Enter 2 for conversion to farenheit");
int b=a.nextInt();
switch(b)
{
case 1:
System.out.println("Enter the temp in farenheit");
double c=a.nextDouble();
double d=5.0/9*(c-32);
System.out.println("The temp in celscius is"+d);
break;
case 2:
System.out.println("Enter the temp in celcius");
double e=a.nextDouble();
double f=1.8*(e+32);
System.out.println("The temp in farenheit is"+f);
break;
default:
System.out.println("Invalid Response,Run again");
}
}
}
More Tutorials