Tutorial JAVA OBJECT ORIENTED PROGRAMMING OOP Concept Abstraction

Tutorial JAVA OBJECT ORIENTED PROGRAMMING

OOP Concept Abstraction means using simple things to represent complexity. We all know how to turn the TV on, but we don’t need to know how it works in order to enjoy it. In Java, abstraction means simple things like objects, classes, and variables represent more complex underlying code and data. This is important because it lets avoid repeating the same work multiple times. Encapsulation. This is the practice of keeping fields within a class private, then providing access to them via public methods. It’s a protective barrier that keeps the data and code safe within the class itself. This way, we can re-use objects like code components or variables without allowing open access to the data system-wide. Inheritance. This is a special feature of Object. Oriented Programming in Java. It lets programmers create new classes that share some of the attributes of existing classes. This lets us build on previous work without reinventing the wheel. Polymorphism. This Java OOP concept lets programmers use the same word to mean different things in different contexts. One form of polymorphism in Java is method overloading. That’s when different meanings are implied by the code itself. The other form is method overriding. That’s when the different meanings are implied by the values of the supplied variables.
![Hello World public class My. Class { public static void main(String[] args) { System. Hello World public class My. Class { public static void main(String[] args) { System.](http://slidetodoc.com/presentation_image_h2/811e3eb91dc59197fe9d98648dc02e3c/image-3.jpg)
Hello World public class My. Class { public static void main(String[] args) { System. out. println("Hello World"); } }

Data Type int my. Num = 5; float my. Float. Num = 5. 99 f; char my. Letter = 'D'; boolean my. Bool = true; String my. Text = "Hello"; // Integer (whole number) // Floating point number // Character // Boolean // String
![String public class My. Class { public static void main(String[] args) { String txt String public class My. Class { public static void main(String[] args) { String txt](http://slidetodoc.com/presentation_image_h2/811e3eb91dc59197fe9d98648dc02e3c/image-5.jpg)
String public class My. Class { public static void main(String[] args) { String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; System. out. println("The length of the txt string is: " + txt. length()); } }
![Math public class My. Class { public static void main(String[] args) { System. out. Math public class My. Class { public static void main(String[] args) { System. out.](http://slidetodoc.com/presentation_image_h2/811e3eb91dc59197fe9d98648dc02e3c/image-6.jpg)
Math public class My. Class { public static void main(String[] args) { System. out. println(Math. max(5, 10)); // output 10 } }
![Math public class My. Class { public static void main(String[] args) { System. out. Math public class My. Class { public static void main(String[] args) { System. out.](http://slidetodoc.com/presentation_image_h2/811e3eb91dc59197fe9d98648dc02e3c/image-7.jpg)
Math public class My. Class { public static void main(String[] args) { System. out. println(Math. sqrt(64)); // Output 8. 0 } }
![If statement public class My. Class { public static void main(String[] args) { int If statement public class My. Class { public static void main(String[] args) { int](http://slidetodoc.com/presentation_image_h2/811e3eb91dc59197fe9d98648dc02e3c/image-8.jpg)
If statement public class My. Class { public static void main(String[] args) { int x = 20; int y = 18; if (x > y) { System. out. println("x is greater than y"); } } }
- Slides: 8