abstarction

Solutions on MaxInterview for abstarction by the best coders in the world

showing results for - "abstarction"
Lucia
08 Mar 2019
1Abstraction: 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
similar questions
abstractin