100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Resumen

Summary Learn java for developer

Puntuación
-
Vendido
-
Páginas
9
Subido en
08-02-2025
Escrito en
2024/2025

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

Institución
Grado









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Libro relacionado

Escuela, estudio y materia

Institución
Grado

Información del documento

¿Un libro?
Subido en
8 de febrero de 2025
Número de páginas
9
Escrito en
2024/2025
Tipo
Resumen

Temas

Vista previa del contenido

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
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
nensiborad

Documento también disponible en un lote

Conoce al vendedor

Seller avatar
nensiborad nav gujarat
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
10 meses
Número de seguidores
0
Documentos
7
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes