Looking for a Tutor Near You?

Post Learning Requirement » x
Ask a Question
x
x

Direction

x

Ask a Question

x

Hire a Tutor

Java Programming

Published in: C++ | JAVA
17 Views

basics of java programming

Roshin S / Sharjah

2 years of teaching experience

Qualification: Masters in computer science

Teaches: IELTS, OET, GED, GATE, Computer Science, English, Science, MS Office, Web Development, C Language, C++, Computer, Maths

Contact this Tutor
  1. 0000 OG Java Programming
  2. OOPS Concepts in Ja va Object -'—Class Encapsulation • • Inheritance Data Abstraction Encapsulation Polymorphism Polymor phism Inheritance a•ject
  3. Object Oriented Programming OOP is the most popular programming paradigm used for software —development. Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects.
  4. Object Any entity that has state and behaviour is known as object. For example, a chair, pen, table, keyboard, —bike, etc. Objects An Object can be defined as an instance of a class. An object contains an address and takes up some space in memory. Example: A dog is an object because it has states like colour, name, breed, etc. as well as behaviours like wagging the tail, barking, etc,
  5. Class Collection of objects is called class. It is a logical entity. A class can also be defined as a blueprint from which you can create an individual object. Class doesn't consume any space. public class Main{ int x = 5;
  6. public class Main( int x = 5; public static void main(String args[]){ TTäTmyObj = new Main(); System.out.println(MyObj.x);
  7. •public : it is a access specifier that means it will be accessed by publically. •static : it is access modifier that means when the java program is load then it will create the space in memory automatically. •void : it is a return type i.e it does not return any value. •main() : it is a method or a function name. •string args[] : its a command line argument it is a collection of variables in the string format.
  8. Encapsulation Binding (or wrapping) code and data together into a single unit are known —as-encapsulation. • For example, a capsule, it is wrapped with different medicines. A java class is the example of encapsulation. Capsule
  9. Terms used in Inheritance •Class: A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. •Sub-Class/Child Class: Subclass is a class which inherits the other class. It is also called a derived class, extended class, or child class. •Super Class/Parent Class: Superclass is the class from where a subclass inherits the features. It is also called a base class or a parent class. •Reusability: As the name specifies, reusability is a mechanism which facilitates you to reuse the fields and methods of the existing class when you create a new class. You can use the same fields and methods already defined in the previous class.
  10. Syntax for Inheritance class Subclass-name extends Superclass-name //methods and fields Employee salary: float Programmer bonus: int
  11. class Employee { float salary=40()OO; -class-Programmer extends Employee { int bonus—10000; public static void main(String args[]){ Programmer p=new Programmer(); System.out.println("Programmer salary is: "+p.salary); System.out.println("Bonus of Programmer is: "+p.bonus);
  12. ClassA ClassB 1) Single ClassA ClassB ClassC 2) Multilevel ClassB ClassA ClassA ClassC ClassB 3) Hierarchical ClassC 4) Multiple
  13. Polymorphism Polymorphism in Java is a concept by which we can perform a single action in different ways. -•—ft-has the ability of a message to be displayed in more than one form. class Bike{ void class Splendor extends Bike{ void safely with 60km");} public static void main(String args[]){ Bike b = new Splendor();//upcasting b.run();
  14. Data Abstraction -'—Hiding internal details and showing functionality is known as abstraction. • For example, phone call, we don't know the internal processing.