5 days ago Learn concept of Object Oriented Programming(OOP) in java with example. Know about OOPS Concepts in Java with Examples. Details: Last Core OOPS concepts are. 1) Class . JavaScript Tutorial for Beginners PDF. advanced concepts related to Java Programming language. For most of the examples given in this tutorial, you will find a 'Try it' option, which . Basic Syntax . Core Java - Free download as PDF File .pdf), Text File .txt) or Let's have a quick look at java programming example. Java OOPs Concepts.

Core Java Concepts With Examples Pdf

Language:English, German, Hindi
Genre:Health & Fitness
Published (Last):24.10.2015
ePub File Size:24.76 MB
PDF File Size:17.28 MB
Distribution:Free* [*Sign up for free]
Uploaded by: JONATHON

provide the core functions of Java. The language package ( contains the lowest level of required classes. For example, includes the Object. This book is intended for people with at least some basic programming back- ground, which During each week, you'll read seven chapters that present concepts related to the. Java For example, a printing code of shows that the. Revision on Basic Java Concepts . ➢Java class has static and non static methods(instance members). ➢Java . Example:Adding constructors to class Radio.

Instance variable doesn't get memory at compile time. It gets memory at runtime when object instance is created. That is why, it is known as instance variable. Method in Java In java, a method is like function i. Advantage of Method Code Reusability Code Optimization new keyword The new keyword is used to allocate memory at runtime. Constructor in java is a special type of method that is used to initialize the object.

Core Java Topics.pdf

Java constructor is invoked at the time of object creation. It constructs the values i. Rules for creating java constructor There are basically two rules defined for the constructor. Constructor name must be same as its class name Constructor must have no explicit return type.

Java Default Constructor A constructor that have no parameter is known as default constructor. Purpose Of Default Constructor Default constructor provides the default values to the object like 0, null etc. It will be invoked at the time of object creation.

If there is no constructor in a class, compiler automatically creates a default constructor. Inheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea behind inheritance in java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of parent class, and you can add new methods and fields also.

Inheritance represents the IS-A relationship, also known as parent-child relationship. Why use inheritance in java For Method Overriding so runtime polymorphism can be achieved. For Code Reusability.

In the terminology of Java, a class that is inherited is called a super class. The new class is called a subclass. Multiple inheritance is not supported in java through class. This Problem is overcome through the Concept of Interface. When a class extends multiple classes i. Why multiple inheritance is not supported in java? To reduce the complexity and simplify the language, multiple inheritance is not supported in java.

Consider a scenario where A, B and C are three classes.

The C class inherits A and B classes. If A and B classes have same method and you call it from child class object, there will be ambiguity to call method of A or B class. Since compile time errors are better than runtime errors, java renders compile time error if you inherit 2 classes. So whether you have same method or different, there will be compile time error now. Compile Time Error.

Polymorphism in java is a concept by which we can perform a single action by different ways. Polymorphism is derived from 2 greek words: The word "poly" means many and "morphs" means forms.

So polymorphism means many forms. There are two types of polymorphism in java: We can perform polymorphism in java by method overloading and method overriding. If you overload static method in java, it is the example of compile time polymorphism.

Here, we will focus on runtime polymorphism in java. Runtime Polymorphism in Java Runtime polymorphism or Dynamic Method Dispatch is a process in which a call to an overridden method is resolved at runtime rather than compile-time.

In this process, an overridden method is called through the reference variable of a superclass. The determination of the method to be called is based on the object being referred to by the reference variable. Let's first understand the upcasting before Runtime Polymorphism. Upcasting When reference variable of Parent class refers to the object of Child class, it is known as upcasting. For example:. But, rate of interest may differ according to banks. SBI Rate of Interest: Encapsulation in java is a process of wrapping code and data together into a single unit, for example capsule i.

We can create a fully encapsulated class in java by making all the data members of the class private. Now we can use setter and getter methods to set and get the data in it.

The Java Bean class is the example of fully encapsulated class. Advantage of Encapsulation in java By providing only setter or getter method, you can make the class read-only or write-only. It provides you the control over the data. Suppose you want to set the value of id i. Simple example of encapsulation in java Let's see the simple example of encapsulation that has only one field with its setter and getter methods.

Compile By: Test Output: Abstraction in Java Abstraction is a process of hiding the implementation details and showing only functionality to the user. Another way, it shows only important things to the user and hides the internal details for example sending sms, you just type the text and send the message. You don't know the internal processing about the message delivery. Abstraction lets you focus on what the object does instead of how it does it.

Ways to achieve Abstraction There are two ways to achieve abstraction in java 1. Abstract Class:: A class that is declared with abstract keyword, is known as abstract class in java.

It can have abstract and non-abstract methods method with body. It needs to be extended and its method implemented. It cannot be instantiated. It implementation is provided by the Honda class. Interface in Java:: An interface in java is a blueprint of a class.

It has static constants and abstract methods only.

Java OOPs Concepts

The interface in java is a mechanism to achieve fully abstraction. There can be only abstract methods in the java interface not method body. It is used to achieve fully abstraction and multiple inheritance in Java. Java Interface also represents IS-A relationship. It cannot be instantiated just like abstract class.

Why use Java interface? There are mainly three reasons to use interface. They are given below. It is used to achieve fully abstraction. By interface, we can support the functionality of multiple inheritance.

It can be used to achieve loose coupling. The java compiler adds public and abstract keywords before the interface method and public, static and final keywords before data members. In other words, Interface fields are public, static and final bydefault, and methods are public and abstract.

Understanding relationship between classes and interfaces As shown in the figure given below, a class extends another class, an interface extends another interface but a class implements an interface. Simple example of Java interface In this example, Printable interface have only one method, its implementation is provided in the A class. Multiple inheritance in Java by interface If a class implements multiple interfaces, or an interface extends multiple interfaces i.

Hello Welcome. Collections in Java Collections in java is a framework that provides an architecture to store and manipulate the group of objects. All the operations that you perform on a data such as searching, sorting, insertion, manipulation, deletion etc.

Java Collection simply means a single unit of objects. What is framework in java. What is Collection framework Collection represents a single unit of objects i. Collection framework represents a unified architecture for storing and manipulating group of objects.

It has:. Hierarchy of Collection Framework Let us see the hierarchy of collection framework.

Desktop Applications such as acrobat reader, media player, antivirus etc.

The java. Java ArrayList class 1. Java ArrayList class uses a dynamic array for storing the elements. It extends AbstractList class and implements List interface. Java ArrayList class can contain duplicate elements. Java ArrayList class maintains insertion order. Java ArrayList class is non synchronized. Java ArrayList allows random access because array works at the index basis.

In Java ArrayList class, manipulation is slow because a lot of shifting needs to be occurred if any element is removed from the array list. Let's see the example of creating java collection. Ravi Vijay Ravi Ajay. Java Map Interface A map contains values based on the key i. Each pair is known as an entry. Map contains only unique elements. Commonly used methods of Map interface:. Entry Entry is the subinterface of Map. So we will access it by Map. Entry name. It provides methods to get key and value.

Methods of Entry interface: A HashMap contains values based on the key. It implements the Map interface and extends AbstractMap class. It contains only unique elements. Example of HashMap class: Entry m: In java, exception is an event that disrupts the normal flow of the program. It is an object which is thrown at runtime. Advantage of Exception Handling The core advantage of exception handling is to maintain the normal flow of the application.

Exception normally disrupts the normal flow of the application that is why we use exception handling. Let's take a scenario: If we perform exception handling, rest of the statement will be executed. That is why we use exception handling in java. There are mainly two types of exceptions: The sun microsystem says there are three types of exceptions: Checked Exception 2.

Unchecked Exception 3. Error Difference between checked and unchecked exceptions 1 Checked Exception The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions e. Checked exceptions are checked at compile-time. Unchecked exceptions are not checked at compile-time rather they are checked at runtime.

Following are the Common scenarios where exceptions may occur Scenario where ArithmeticException occurs If we divide any number by zero, there occurs an ArithmeticException. Suppose I have a string variable that have characters, converting this variable into digit will occur NumberFormatException. Java try block Java try block is used to enclose the code that might throw an exception. It must be used within the method. Java try block must be followed by either catch or finally block.

It must be used after the try block only.

You can use multiple catch block with a single try. Problem without exception handling Let's try to understand the problem if we don't use try-catch block. Exception in thread main java. He outlines both benefits and drawbacks of Microservices and explains to them how to implement them using popular frameworks like DropWizard and Spring Boot.

This free Java book is full of useful examples. Since data structure and algorithm are very important for any Java programmer and quite a common topic in Java interview, it is an absolute must to have a strong command in both.

If you are preparing for Java job interviews then you can also take a look at some of my favorite algorithm and data structures questions, it may help in your preparation. If you like to read paperback edition, you can order it from site as well.

You can download entire books as PDF, along with all example programs. Carl Albing and Michael Schwarz has done an excellent job to put everything needed to run and support a Java program in Linux environment including how to start, stop, or kill Java process, checking logs with some handy useful UNIX commands. Paperback edition of this book is also available here in site. Core Servlets and Java Server Pages, teaches you basics of these technologies.

The good thing about this Java books is that source code and lecture notes are also available for FREE download. If you like to read paper book then you can also download, paperback edition of this book here Steele Jr. If you like paperback edition, you can also download this books from site here. Paperback edition of this Java book is also available for download on site, here.

All tutorials are available online and you can also download them for free as eBook, available in both. If you love paperback edition, you can also order it from site.

By the way, these tutorials are really good quality and the great way to explore different features of Java Programming language. The third edition of this books is freely available for download and you can download them as PDF format for the offline read.

One more thing, first six chapters of Thinking in Java 4th edition is also available in PDF format for free download.

I liked the chapter on Linked Data structure and Recursion, which teaches some of the key programming concepts with simple, non-trivial Java examples. You can also download paperback edition of this book on site. You often need to work with XML files in large projects, as it's one of the most widely used data transport formats. This Java book is a comprehensive and up-to-date collection of various XML technology and how to use them with Java programming language.

You will learn about different XML parsers e. If your work involves, XML and Java, then this is the book you should read.Javier Solis.

Just be sure not to mix them up : All in all, this is a book with an obvious focus on practice, so you can use it as an additional source for the enhanced studying. Error Difference between checked and unchecked exceptions 1 Checked Exception The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions e.

Many types: Class Method Area: Class Area stores per-class structures such as the runtime constant pool, field, method data, and the code for methods.

Some of them are as follows:.

So object is the instance result of a class. JavaScript and VBScript are examples of object-based programming languages. Suppose you want to create a Banking Software with functions like Deposit Show Balance Unstructured Programming Languages The earliest of all programming language were unstructured programming language.

Whenever needed, a simple call to the function is made. It is profound research about the core concepts of Java which explains the code by line and guides you from the basic understanding of data types, classes and objects to more complex concepts like lambda expressions and functional interfaces.