Core Java Basics - OOPS Concepts

Introduction:  • Java is a high-level programming language, where one can write computer applications like games, web pages, graphics ...

Introduction: 

• Java is a high-level programming language, where one can write computer applications like games, web pages, graphics and data processing … etc. 
• Java language is called as an Object-Oriented Programming language 

Basic Concept of OOP (Object-Oriented Programming): 

There are some basic concepts of object oriented programming as follows:
 
1. Classes 
2. Object 
3. Data abstraction 
4. Data encapsulation 
5. Inheritance 
6. Polymorphism 

Classes 
• A class is a set of objects with similar attributes, common behavior, and common link to other objects. In other words, a class is a collection of objects of similar type. 
• In below example, we will create an object Language belonging to the class India. The corresponding objects develop their distinctiveness from the difference in their attribute value and relationships to other objects. 

Object 
• Objects characterize literally everything 
• Each object holds data and some methods to operate on the data. Example: Representation of object ―LAPTOP

Example Object:                                  Laptop                                                     
                                                           Brand Name
   Data :                                                      OS
                                                                   Cost
Functions :                                               Start()
                                                                  Debug()
                                                                   Stop() 

How to define Classes, Methods and Constructors



Data Abstraction:• The mechanism to create new data types that are useful for an application. In other words it allows the creation of user defined data types.
• Classes use the concepts of data abstraction.
Example:


Data Encapsulation:• Data Encapsulation means wrapping of data and functions into a single unit (i.e. class). It is one of the most useful property of class. The data is not easy to get to the outside world and only those functions which are enclosed in the class can access it.
• It is also called Data Hiding

Press1. Deposit
2. Withdraw
3. Determine Balance
4. Transfer Funds
5. exit

Abstract Class Declaration:• An abstract class is a class that is declared as abstract. It may or may not include abstract methods. 

Example:
public abstract class Television
{
// declare fields
// declare methods
void SwitchOn();
}

Inheritance: • Inheritance is the procedure by which objects of one class can get the properties of objects of another class.
• Inheritance allows the important feature of OOP that is reusability.
• In the example given for class, Telangana, and A.P are part of the class Telugu speaking states and again the Telugu speaking states car is the part of the class Language. The Language is again part of the class India. India is the parent class.

General Declaration of Inheritance class using Keyword extends:

class subclassname extends superclassname
{
Varables;
Methods;
…..
}

Example

class Telangana extends Telugu-Speaking-States
{
Varables;
Methods;

}
class AP extends Telugu-Speaking-States
{
Varables;
Methods;
….. }


Polymorphism: • (Poly means ―many and morph means ―form). Polymorphism means the ability to take more than one form.

Features of Java Program:
• 1. Compiled and Interpreted
• 2. Platform Independent and portable
• 3. Object- oriented
• 4. Robust and secure
• 5. Distributed
• 6. Familiar, simple and small
• 7. Multithreaded and Interactive
• 8. High performance
• 9. Dynamic and Extensible

Java compilation Process


Java Hello World Program:
class HelloWorld {
public static void main(String args[]) {
System.out.println(“Hello World”);
}
}
  • The file name be HelloWorld.java equivalent to the class name containing the main method. 
  • Java is case sensitive. 
  •  public static void main (String [] args ) shows where the program will start running. 
The program outputs the character in between the quotes when executed.
Data types in Java :

Data Types in Java are of two types:
  • primitive data type 
  • non-pimitive data type 
In non-pimitive types, there are three categories
  • classes 
  • arrays 
  • interface 
Primitive data types :


Tokens in Java:
1. Literals 2. Identifiers 3. Operators 4. Separators

Literals in Java are constant values. They can be either Integer or Floating point or Character or String or Boolean literals

Identifiers are programmer named tokens. They are used for naming classes, methods, variables, objects, labels, packages and interfaces in a program.

Separators:
  •  ( ) 
Encloses arguments in method definitions and calling;
Adjusts precedence in arithmetic expressions;
Surrounds cast types and delimits test expressions in flow control statements

  •  { } 
Defines blocks of code and automatically initializes arrays

  • [ ] declares array types and dereferences array values 
  •  <> Declares Generics and Collections 
  •  ; terminates statements 
  • , Separates successive identifiers in variable declarations; 
            Chains statements in the test, expression of a for loop
  • . Selects a field or method from an object; separates package names from sub-package and class names 
  • : Used after loop labels 
Operators:
1. Arithmetic operators 2. Logical operators 3. Relational operators 4. Assignment operators 5. Conditional operators 6. Increment and decrement operators 7. Bit wise operators

Keywords:
In Java language 50 words are reserved for specific purpose. They cannot be used in naming variables, classes and methods. Following are some example keywords.

Double, abstract, char, catch, Boolean, default, finally, do, implements, if, private, public, and static …etc.

Control Structure in Java:
In java program, control structure is can divide in three parts:
  •  Selection statement like – (1) if statement and (2) switch statement 
  •  Iteration statement like - (1) for loop (2) while loop (3) do-while loop 
  •  Jumps in statement like 
break keyword use for exiting from loop and

continue keyword use for continuing the loop.
Name

Android,9,Big Data,3,Cloud Apps,1,Database,1,Featured,12,Free Downloads,1,HowTo,1,IOT,7,Java,1,Linux,1,News,6,Products,1,SEO,1,TipsnTricks,5,Ubuntu,1,Unity3D,4,Windows Apps,1,
ltr
item
Tech Geek Bytes - A Blog For News, Tutorials, Free Source Code, Tips and Tricks: Core Java Basics - OOPS Concepts
Core Java Basics - OOPS Concepts
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8QEBcf_tEQNFTY_w_kW6a8RhkkPG0U_7j_Ki31jLOTVGS2C0ulCEuntilqpxDGDXuI2y-u75ik6ct6A-Pw0zfEIfhjlnqQtoif7PeKvLejsnLAmq2vg2sB5ezMQMEgUidxSFQtgga5GA/s320/java1.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8QEBcf_tEQNFTY_w_kW6a8RhkkPG0U_7j_Ki31jLOTVGS2C0ulCEuntilqpxDGDXuI2y-u75ik6ct6A-Pw0zfEIfhjlnqQtoif7PeKvLejsnLAmq2vg2sB5ezMQMEgUidxSFQtgga5GA/s72-c/java1.png
Tech Geek Bytes - A Blog For News, Tutorials, Free Source Code, Tips and Tricks
https://techgeekbytes.blogspot.com/2017/05/core-java-basics-oops-concepts.html
https://techgeekbytes.blogspot.com/
https://techgeekbytes.blogspot.com/
https://techgeekbytes.blogspot.com/2017/05/core-java-basics-oops-concepts.html
true
8751912191394201619
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy