100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary Learn java for developer

Rating
-
Sold
-
Pages
9
Uploaded on
08-02-2025
Written in
2024/2025

Summary study book Java of Walter J. Savitch, Frank M. Carrano - ISBN: 9780136072256 (Java learn)

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Course

Document information

Summarized whole book?
Yes
Uploaded on
February 8, 2025
Number of pages
9
Written in
2024/2025
Type
Summary

Subjects

Content preview

Unit-3 Exception handling And Inheritance

Interface and abstract class

 Abstraction in Java: -
o A class which is declared with the abstract keyword is known as an abstract
class in java. It can have abstract and non-abstract methods (method with the
body)
o Abstraction is a process of hiding the implementation details and showing
only functionality to the user.
o it shows only essential things to the user and hides the internal details, for
example, sending SMS where you type the text and send the message. You
don't know the internal processing about the message delivery.



 Ways to achieve abstraction: -
1. Abstract class
2. Interface
1. Abstract class: -
o A class which is declared as abstract is known as an abstract class. It can
have abstract and non-abstract methods. It needs to be extended and its
method implemented. It cannot be instantiated.
o An abstract class must be declared with an abstract keyword.
o It can have abstract and non-abstract methods.
o It cannot be instantiated.
o It can have constructors and static methods also.
o It can have final methods which will force the subclass not to change the body
of the method.
o Syntax: - abstract class A{ }
o Example: -

abstract class Shape {
abstract void draw ();
}
//In real scenario, implementation is provided by others i.e. unknown by end user
class Rectangle extends Shape{
void draw(){System.out.println("drawing rectangle");}
}
class Circle1 extends Shape{
void draw(){System.out.println("drawing circle");}

, }
//In real scenario, method is called by programmer or user
class TestAbstraction1{
public static void main(String args[]){
Shape s=new Circle1();//In a real scenario, object is provided through method, e.g.,
getShape() method
s.draw();
}
}
o An abstract class can have a data member, abstract method, method body
(non-abstract method), constructor, and even main() method.
o Example: -
abstract class Bike{
Bike(){System.out.println("bike is created");}
abstract void run();
void changeGear(){System.out.println("gear changed");}
}
//Creating a Child class which inherits Abstract class
class Honda extends Bike{
void run(){System.out.println("running safely..");}
}
//Creating a Test class which calls abstract and non-abstract methods
class TestAbstraction2{
public static void main(String args[]){
Bike obj = new Honda();
obj.run();
obj.changeGear();
}
}


 Interface: -
o An interface in Java is a blueprint of a class. It has static constants and
abstract methods.
o The interface in Java is a mechanism to achieve abstraction. There can be
only abstract methods in the Java interface, not method body. It is used to
achieve abstraction and multiple inheritance in Java.
$9.79
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
nensiborad

Also available in package deal

Get to know the seller

Seller avatar
nensiborad nav gujarat
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
10 months
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions