JAVA
By, RAJKIRAN EDUNURI B.Tech Computer Science, Guru Nanak Institutions,Hyderabad
e-mail : rajkiranedunuri97@gmail.com
Website : rockzzweb.wordpress.com
JAVA By, RAJKIRAN EDUNURI B.Tech Computer Science, Guru Nanak - - PowerPoint PPT Presentation
JAVA By, RAJKIRAN EDUNURI B.Tech Computer Science, Guru Nanak Institutions,Hyderabad e- mail : rajkiranedunuri97@gmail.com Website : rockzzweb.wordpress.com JAVA What is JAVA Why Java has Become More Popular *** Java is Case Sensitive
By, RAJKIRAN EDUNURI B.Tech Computer Science, Guru Nanak Institutions,Hyderabad
e-mail : rajkiranedunuri97@gmail.com
Website : rockzzweb.wordpress.com
JAVA
What is JAVA Why Java has Become More Popular
*** Java is Case Sensitive language
What is JAVA
Simply, JAVA is an “OBJECT ORIENTED PROGRAMMING LANGUAGE”
What is OBJECT ORIENTED PROGRAMMING (OOPS)
method that combines :
self-sufficient ‘Object’ that can be used within a program or in other programs..
(Important for interviews)
CONCEPTS IN OBJECT ORIENTED PROGRAMMING..
Why Should i learn OOPS
Easy..
event much more Efficiently.
Java Editor or IDE’S
System..
platform
class class_name { public static void main (String [ ] args ) { // Statement 1; // Statement 2; } }
Structure of Java program
Java is Case Sensitive language
Simple Java Hello World Program
public class hello_world { public static void main (String[ ] args) { System.out.println(“ HELLO WORLD ”); } }
Output : HELLO WORLD
Save Above program with “ hello_world.java “ without Quotes
Explanation of Previous program
class as public, it means that we can access that method/class anywhere in the program…
java we write any method/any logic inside the class )
What is a METHOD…???
Statement1; Statement2; }
statement1; statement2; }
CLASS
called CLASS
class..
same, else it will throw an exception that “ Class names Not matched”…
OBJECTS
Methods
constructors Present inside a class , in other class…
Program to understand concept of Objects
class my_bio { /* Writing method */ /* method is nothing but a function to perform some operation */ void bio_data () { /* Creating method */ String name=“shashi”; String college=“Malla Reddy Institute of technology”; int age=20; System.out.println(“Name : ”+name); System.out.println(“ College : ”+college); System.out.println(“Age : ” +age); } public static void main (String [] args ) { my_bio ob =new my_bio(); /* Created Object to access method */
} }
Save Above with “ my_bio.java ”
Output : Name : shashi college : Malla Reddy Institute of technology Age : 20
inside the class we have written Some code to the method ( public void bio_data () )
( ob ) to class (my_bio) and Called method using “
which Results the Above Output..
ABSTRACTION
Required data..
large data..
Program tp Understand concept of ABSTRACTION
class Abstraction { Public static void main(String [ ] args ) { String name=“Shashi”; String college=“Malla Reddy Institute of Technology”; int age=20; String address=“HYDERABAD”; System.out.println(“Name : ”+name); System.out.println(“College : ”+college); System.out.println(“Address : ”+ address); } }
Save Above Program with “ Abstraction.java ”
OUTPUT :
Name: Shashi College : Malla Reddy Institute of Technology Address : HYDERABAD
instances variables ( name, college, age,Address)
Name,College,Address ,but not Age
displayed them and hid the Age variable..
methods but with same Method Name..
WILL BE SAME BUT OPERATIONS PERFORMED ON METHOD WILL BE DIFFERENT ”
POLYMORPHISM
Program to Understand Polymorphism
class polymorphism { void calculate(int x) { return sqrt(x); } void calculate(int x) { return (x*x); } Public static void main(String [ ] args ) { Polymorphism ob =new polymorphism(); System.out.println(“Square Root is : ”+ob.calculate(25)); System.out.println(“Square of x is : ”+ob.calculate(2)); } }
Save Above with “ polymorphism.java ”
Output : Square Root is 5 Square is 4
(polymorphism) and created 2 methods (calculate) with Same name but operations performed on them was Different..
Root of a number..
Squaring of a number..
ENCAPSULATION
Process of Binding The Data of variables
same, but values of them will be different..
Program to Understand ENCAPSULATION
class a { /* Super Class 1 */ String name=“Shashi”; String college=“Malla Reddy Institute of Technology”; void method1(){ System.out.println(“Name : ”+name); System.out.println(“College : ”+college); } } class b { /* Super class 2 */ String name=“Rajkiran”; String college=“Guru Nanak Institutions”; void method2() { System.out.println(“Name : ”+name); System.out.println(“College : ”+college); } } class encapsulation { /* Sub class */ public static void main(String [ ] args ) { a ob1=new a(); b ob2=new b();
} }
Save with “ encapuslation.java ” as main method is present in sub class
Output : Name : shashi College : Malla Reddy Institute of Technology Name : Rajkiran College : Guru Nanak Institutions
classes ( 2 super and 1 sub class) Created 1 method in each Super class (variable names are same, but values of them are Different..)
class, which results above output…
INHERITANCE
properties of another class…
class
( Important )
Program to understand INHERITANCE
class a { void method1() { /* creating a method */ String name=“Shashi”; String college=“Malla Reddy Institute of Technology”; System.out.println(“Name : ”+name); System.out.println(“College : ”+college); } } class b extends a { void method2() { /* creating a method */ String name=“Rajkiran”; String college=“Guru Nanak Institutions”; System.out.println(“Name : ”+name); System.out.println(“College : ”+college); } } class inheritance { public static void main(String [ ] args ) { a ob1=new a(); /* Object to class a */ b ob2=new ob2(); /* Object to class b */
} }
Save code with “ inheritance.java ”
Output
Name : Shashi College : Malla Reddy Institute of Technology Name : Rajkiran College : Guru Nanak Institutions Name : Shashi College: Malla Reddy Institute of Technology
and written 2 methods ( 1 in class a and 1 in class b)…
for class a and ob2 for class b)
Explanation
THANK YOU
By, RAJKIRAN EDUNURI B.Tech Computer Science, Guru Nanak Institutions,Hyderabad
e-mail : rajkiranedunuri97@gmail.com
Website : rockzzweb.wordpress.com