abstraction in java

Solutions on MaxInterview for abstraction in java by the best coders in the world

showing results for - "abstraction in java"
Ida
23 Mar 2016
1Abstraction is defined as hiding internal implementation and showing only 
2necessary information.
3// abstract class
4abstract class Addition
5{
6   // abstract methods
7   public abstract int addTwoNumbers(int number1, int number2);
8   public abstract int addFourNumbers(int number1, int number2, int number3, int number4);
9   // non-abstract method
10   public void printValues()
11   {
12      System.out.println("abstract class printValues() method");
13   }
14}
15class AbstractMethodExample extends Addition
16{
17   public int addTwoNumbers(int number1, int number2)
18   {
19      return number1 + number2;
20   }
21   public int addFourNumbers(int number1, int number2, int number3, int number4)
22   {
23      return number1 + number2 + number3 + number4;
24   }
25   public static void main(String[] args)
26   {
27      Addition add = new AbstractMethodExample();
28      System.out.println(add.addTwoNumbers(6, 6));
29      System.out.println(add.addFourNumbers(8, 8, 3, 2));
30      add.printValues();
31   }
32}
Anna
29 Oct 2016
1bstraction: Hiding the implementation details, 
2concentrating on essentials things, 
3without worrying about the details 
4■ In java, abstraction is achieved via abstract class or interface 
5Abstraction cannot exist without inheritance 
6
73.1. Abstract class a class that's meant to be inherited 
8(cannot be private or final)
9To create an abstract class: add keyword abstract 
10before the class declaration 
11A class that we cannot create object 
12when abstract class extended by regular class: 
13we MUST override all the abstract methods of super class
14when abstract class extended by abstract class: 
15no need to override any abstract methods
16
17abstract class vs non-abstract class:
18NON-ABSTRACT CLASS:
19cannot have: abstract methods
20can have: constructor, instance method, static method, 
21instance block, static block, instance variable, static variable
22ABSTRACT CLASS:
23can have: constructor, instance method, static method, instance block,
24static block, instance variable, static variable...
25ABSTRACT METHOD: method without implementation, meant to be override 
26(cannot create object, cannot be final,static,private)
27
28FRAMEWORK EXAMPLE:
29In my framework I have achieved abstraction by using collections 
30or Map, because its all interface. Most of the cases I come 
31across using List. If we want to access elements frequently 
32by using index, List is a way to go. ArrayList provides 
33faster access if we know index. If we want to store elements and 
34want them to maintain an order, List is a better choice. 
35i) List webs = driver.getWindowHandles();    
36=>create a list first to store web URLs in list
37ii)To handle dynamic elements store it in the list and identify by index
38List all = driver.findElements(By.tagname(“”));
39In my framework I follow POM and had situations where some pages 
40shared similar actions that were similar but worked slightly 
41different, so I was able to use abstraction to define those 
42actions and implement them in each page according to what was needed 
43for that webpage
Angelique
08 Jun 2017
1Abstraction is nothing but the quality of dealing with ideas rather than 
2events. It basically deals with hiding the internal details and showing 
3the essential things to the user.
Moritz
27 Oct 2019
1// abstraction in java with example
2// abstract class
3abstract class Addition
4{
5   // abstract methods
6   public abstract int addTwoNumbers(int number1, int number2);
7   public abstract int addFourNumbers(int number1, int number2, int number3, int number4);
8   // non-abstract method
9   public void printValues()
10   {
11      System.out.println("abstract class printValues() method");
12   }
13}
14class AbstractMethodExample extends Addition
15{
16   public int addTwoNumbers(int number1, int number2)
17   {
18      return number1 + number2;
19   }
20   public int addFourNumbers(int number1, int number2, int number3, int number4)
21   {
22      return number1 + number2 + number3 + number4;
23   }
24   public static void main(String[] args)
25   {
26      Addition add = new AbstractMethodExample();
27      System.out.println(add.addTwoNumbers(6, 6));
28      System.out.println(add.addFourNumbers(8, 8, 3, 2));
29      add.printValues();
30   }
31}
Emely
25 Jul 2020
1Sometimes we may come across a situation
2where we cannot provide implementation to
3all the methods in a class. We want to leave the 
4implementation to a class that extends it.
5  In that case we declare a class
6as abstract by using abstract keyword on method
7signature.In my framework I have created my
8PageBase class as super
9class of the all page classes. 
10I have collected all common elements
11and functions into PageBase class and
12all other page classes extent PageBase class.
13By doing so, I don't have to locate very
14common WebElements and it provides
15reusability in my framework.
16Also
171)Abstract classes cannot be instantiated
182)An abstarct classes contains abstract method,
19concrete methods or both.
203)Any class which extends abstarct class must
21  override all methods of abstract class
224)An abstarct class can contain either
23  0 or more abstract method.   
Nicola
19 Aug 2020
1// example on abstract class in java
2import java.util.*;
3// abstract class
4abstract class Shape
5{
6   // abstract method
7   abstract void sides();
8}
9class Triangle extends Shape
10{
11   void sides()
12   {
13      System.out.println("Triangle shape has three sides.");
14   }
15}
16class Pentagon extends Shape
17{
18   void sides()
19   {
20      System.out.println("Pentagon shape has five sides.");
21   }
22   public static void main(String[] args)
23   {
24      Triangle obj1 = new Triangle();
25      obj1.sides();
26      Pentagon obj2 = new Pentagon();
27      obj2.sides();
28   }
29}
queries leading to this page
abstraction in java javawhat is the abstract method in javajava example of abstractionabstractionin javawhat is java abstracitonabstraction examples in javaabstract class jacajava data abstractionwhat is java abstractionabstract method javasyntax of abstraction in javaabstract class definaan abstract class inherit non abstract class javawhere do we use abstraction in javaabstraction in oops javahow abstraction works in javasignificance of abstraction in javaabstraction in java meaninghow can we implement abstraction in javaabstraction in java code 5cmaking an abstract class in javawhat is abstraction in java with exampleabstraction in javaabstract classabstraction classsample code for abstraction in javawhat is abstract classobject abstractionabtaction in javawhich of the following is false about abstract classes in javaabstraction in kjavaabstraction example jajava abstract constructorabstraction java exampleabstraction using classesjava abstract class variables define abstraction methods in abstract class javaconcept of abstraction in javajava abstraction syntaxclass level abstraction in java with example abstraction definitionabstract method in java interface why do we need abstraction in javajava abstract classabstraction code in javaconstructor in abstract class in javaabstraction examplejava why use abstraction examplewhat is abstractions in javamethod abstraction in javadefine abstractionhow to use abstraction in java codejava inheritance abstraction programswhat is abstract in javaabstractions meaning javaabstraction program example in javaclass is abstraction and object is abstractiondata abstraction features supported by javaexample of abstraction javaabstraction java how what why need abstraction in javawhat abstraction in javaabstraction inn javafull abstraction cin javaabstraction in classabstraction in java code abstraction meaningwhat is the definition of abstraction in javaabstraction in java with examplepublic abstract classabstract classes javajava abstract interfaceabstract method in javacontrol abstraction in javaabstrct classes javahow to wrinte abstraction in javaabstractionwhat is data abstraction in javajava what is abstractionabstraction in java example codeabstraction code example in javaabstraction and interface in javaabstraction defintion javajava abstractvwhat is an abstraction in java 3fwhat is the abstract classabstracting in javacontrol abstraction example in javaabstraction java implementation javaexample abstraction in javaabsraction in javawrite the two ways to achieve abstraction in java abstraction in java with example program with outputabstract class javawhat is class abstraction in javaabstraction syntax in javajava oop abstraction methodswhich is complete abstraction is javajava abstraction examplejava why use abstractionis java string class abstractcontrol abstraction in java with examplesabstraction with example in javaabstract classes in java gfgexamples for abstraction in javahow to make an abstract class javaabstraction in java oopcreate abstract class javaabstract class and methdos in javawhat is abstration in javawrite a method to demonstrate abstract classes function in javainterface and abstraction in javaunderstanding abstraction in javahow does java use abstractionabstractions javais am implement class an abstract class in javaexample of an abstraction javaabstract javatwo ways to achieve abstraction in javaabstraction definition javaabstraction 2b javajava abstraction definitionwhat is abstraction javawrite the two ways to achieve abstraction in javaabstraction implementation in java examplecreate object abstract class javaabstraction java codejava oop abstractionjava abstractionwhen to use abstraction and interface in javawhat i s abstract classdata abstraction javadefine abstraction in javawhen to use abstraction in javaabstract java meaningabstration in javahow do you implement abstraction in javajava abstractionscomplete abstraction in javaabstraction interface in javawhat is the abstract keyword in javaabstraction in javsawhat is abstraction java 5djava program for abstractionadvantages of abstraction in javajava abstract class with variableswhat an abstract class isuse of abstraction in javaabstraction java programizabstract code exampleabstraction in java what does abstract do in javawhat is abstract class in oop javaabstraction example in java 27java abstract methodhow can we achive abstraction in javajava abstract class usage exampleusage of abstraction in javaabstract meaning javaa class is abstraction and object is abstractionjava abstractabstraction en javatypes of abstraction in javaabstraction in javascript w3schoolswhat is an abstract classwhy abstraction is used in javawhat is abstraction in in javaabstraction meaning in javaabstract class abstract methodabstraction java explainedabstract class in java gfgmethod abstractionabstraction meaning in englishwhat is meant by abstraction in javahow can we make a class abstract in javaabstraction in java meningabstract class construtor javaabstraction with interface in javaabstraction in javameaning of abstractionoops abstract example in javadata abstraction in javahow can we apply abstraction in javawhat is abstraction in oop javaabstract class in javabest example for abstraction in javaabstract meaning in javawhy is important the abstraction in javahow can we implement abstraction in java 3fabstraction oin javawhat is abstraction in java 3fabstraction in java code samplesabstract class definitiongeeks java abstractionhow we use abstraction in java 3fabstract methods and class in javaabstraction in jjavawhat is a abstract classabstractio in javaabstract in java full tutorialhow do abstract classes work in java abstraction in java with exampleabstraction implementation in javahow abstraction is implemented in javaabstraction use in javajava abstract class with codeconcept to implement abstraction in javawhat is abstractionabstraction in programming javaclass abstractionexamples of abstraction in javaabstraction and interface javaabstract function in javawhy abstract class is used in javapurpose of abstraction in javahow to achive abstarction using absatrcy class in javaabstraction meaningwhen use abstract class and interface javawhat is the purpose of abstraction in javaoops abstraction example in javaabstraction in java coding examplewhat is abstraction in java with example 3fclass abstraction in javaabstraction in a javajava abstraction meaningwhat is use of abstraction in javawhat is class abstractionabstraction in jabawhy do we need abstract class in java real time examplewhat is the abstraction in javaabstraction ib javawhat is an example of abstraction in javaabstract classes in javadiscuss abstraction in java with suitable exampleimplement abstraction in javacreate abstract class in javaexample of abstraction in javaabstraction meaning javajava abstract variablejava abstraction classabstraction program in java control abstraction in java examplewhat is abstraction in detailwhat is abstraction in javajava property abstract classabstraction example in javahow to use abstraction in javaabstraction definationabstraction in java exampleabstraction methode in javaabstraction in java definitionabstraction program in java exampleabstraction definwhen we use abstraction in javadata abstraction meaning in javaimplementation of abstraction in javaabstraction example program in javaabstractiion example in java 27what is the meaning of abstraction in javahow to write abstract method in javaabstract class and method in javaabstractions in javaa subclass can be an abstract class in java 3fabstraction meanwhere to use abstraction javawhy use abstraction in javawhat is the meaning of abstractionabstraction in javavdefinition of abstraction in javawhy we need abstraction in javawhat are abstract classes 3flevel of abstraction in javameaning of abstraction in javaabstract classes in java 2c provide subclass based on stringwhat is abstract class 3f abstract w3schoolswhat is an abstract calsswrite short note on inheritance and abstraction in java with exampleexamples of data abstraction features supported by javaabstraction cod in javawhat is the abstraction in java 3fabstraction in java javatpoiitnabstraction in java is implemented usingabstration javaabstraction in java whywhat are abstraction in javaabstraction example javaabstract static class in javaabstraction in jvaaabstraction means in javaabstraction javawhy we use abstraction in javadefinition of abstraction javajava abstraction simple exampleabstraction definition in javawhat is abstraction in javaobsraction in javahow to do abstraction in javawhy we use abstract class in javabest example of abstraction in javaabstract class in java w3schoolsabstraction in java