Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views

Java Start

The document discusses Java programming language. It provides an introduction to Java, describing its features like platform independence, object oriented concepts, robustness, security and performance. It also covers Java versions, Java development kit, runtime environment and types of Java applications. The document further explains Java concepts like classes, objects, methods, variables, data types, constructors and access modifiers.

Uploaded by

Praveen Devnani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Java Start

The document discusses Java programming language. It provides an introduction to Java, describing its features like platform independence, object oriented concepts, robustness, security and performance. It also covers Java versions, Java development kit, runtime environment and types of Java applications. The document further explains Java concepts like classes, objects, methods, variables, data types, constructors and access modifiers.

Uploaded by

Praveen Devnani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

C-->loc(line of code) memory-performance low

C++-->pointers
---Introduction to Java---
Developed by Sun microsystems in 1991
Originally -->Oak
Oracle Corporation-2010

---Java Feature----
1.Platform independent-windows,linux,macintosh.

2.Object Oriented Programmings(OOPS) concepts:-

a.Inheritance
b.Polymorphism
c.Encapsulation
d.Abstraction

3.Robust
-Garbage collector and Exception Handling
a/b;
a=9;
b=0;
try{
c=a/b;
res=c;

}catch(Arithematic Exception)
{
System.out.println("invalid division");
}

4.Secure
5.High Performance
6.byte code---
.java
jvm-Java virtual machine
.class file

Java8-
jdk-->java development kit-SE,EE-1.7,1.8

jre-->java runtime environment

Interface-abstract class{
method body
boo();

boo();
Syso("Hi");
meow();

7.Multithreading
sync task
async

Eclipse
jre-jar file
8gb

--Types of application--
Front End--UI
Back End--Tabular

1.Web application--Servlet,jsp,Spring,Hibernate-dynamic page(responsive page)


2.Mobile app--Java ME-->android app-->xml
3.Standalone application-Music player,antivirus--Swing,AWT
4.Enterprise app-banking app,real-time app--Security maintained-

--Class Syntax--
object--method is called using object
methods--implementation (action to be performed)
add()
a=
b=
c=a+b

Instance variable--
constructors--if object is created then bydefault jvm creates its default
constructor.

Lights();
constructor--initialize the objects. It is called when object of class is created
class -Employee-- int e_id,String e_name,int age,float salary,float
experience--parameters
---default constructor--Employee();

--parameterized constructor--Employee1(int e_id,e_name,float salary)


this.e_id=e_id;

Employee();
Employee1();

access modifiers
public--class can be accessed anywhere
package name-com.lti
----9 classes
com.lti.service
---classes
private--cannot be accessed outside the class
private int company ps no=907686;--java1
default--can be accessed in the same package outside the defined class
protected--

---Java Program---

class Lights{
boolean isOn; //boolean--datatype--true/false
Void turnOn(){ //void--nothing
isOn=true;
System.out.println("Light is on" +isOn); +-->concatenate -->Light is on true
}

void turnOff(){
isOn=false;
System.out.println("Status of lighton is " +isOn);
}
public static void main(Strings[] args){
Lights l1=new Lights(); ------//Lights(); --->default constructor

Lights l2=new Lights();

l1.turnOff(); //-->status of lighton is false


12.turnOn(); //-->Light is on true
}

--Variables--
.local variable--defined inside the body of the method.
.Static variable--value of variable is fixed.. static pi=3.14--cannot be
modified..memory save
static int data=80;
data=90;
print 80

.Instance variable--declared inside the class but we can use this variable outside
the class and it cannot be static.

---Datatypes--
.Numbers-int,float,double,long,byte
.Character and String-char
string is enclosed in double quotes
syntax of string
String s1="who is playing?";
String s2="And where?";
String s3=s1+s2;
.boolean-true or false

Variables
int a=
char b=

3 types of variables
local variable
instance variable
static variable

Class Area{
int Area1; //instance variable(inside the class)
Area of square=(Side)*(Side);
System.out.println(Area1);
}

Void square(){
int s=9; //local variable(inside the method)
}

Static int a=9;//value is fixed


a++;
Syso(a);-->9

Circle Area=pi*r*r;
static float pi=3.14

--Multiple methods and classes--

public class Computer{


Computer(){
Syso("Computer is ok");
}
void computer_method(){
Syso("Power off");
}
public static void main(String args[]){
Computer c=new Computer();
c.computer_method();

}
}
Method can have a return type but constructor cannot

Constructor :
-Block of code that is similar to method.
-it is called when an instance of class(Object)is created.
Rules:
-->Constructor name-->Class name
-->have no return type
-->cannot be static,final,synchronized,abstract.

Constructor:Computer()-->Default constructor(No arg/Non parameterized


constructor)--Java creates by default
Eg:
class Student{
int id;
String name;

void display(){
System.out.println(id+" "+name);
}
public static void main(String args[]){
Student s1=new Student();//0 null
Student s2=new Student();//0 null
s1.display();
s2.display();

}
}
Parameterized constructor
class Student{
int id;
String name;
//creating a parameterized constructor
Student(int id,String name)

void display(){
System.out.println(id+" "+name);
}
public static void main(String args[]){
Student s1=new Student(1,"Ashish");//1 Ashish
Student s2=new Student(2,"Pawan");//2 Pawan
s1.display();
s2.display();

}
}

You might also like