Menu
College to Corporate
Introduction to Object Oriented Programming – Java basics Hidden implementation or Abstraction
The solution to a problem is now divided into class creators and client programmers. Client programmers will collect the classes created by the class creators to develop an application. Now the aim of a class creator will be to build a class that will expose only the necessary information for the client programmer and make the rest of the information will not be allowed to be accessed by anyone. This process of hiding the information is called as Abstraction. But why are we doing this abstraction? There are two important reasons for this abstraction.
Reusing the implementation or Inheritance Reusing a code is one of the biggest advantage of the object-oriented programming language provides. The simplest way of reusing a class is to directly place an object of the class inside a new class. Thus we can create a new class with number of objects of different type. This way of creating a new class from the existing classes is called as composition and this is referred as has-a relationship. For example, “A book has pages” where book is a new class that contains any number of objects of class page. Another example, “A car has an engine” where car is a new class that contains an object of the class engine. In composition, the objects of the existing classes will always be private in the new class making it inaccessible for client programmers directly. The other way of reusing the implementation is through inheritance. We undergo a lot of trouble while we create a class and create a new class that looks similar in the functionality. Will it not be nicer when you can clone an existing class and add or modify the cloned class to create a new class? The class that from which we are cloning a new class is called as base class or super class or parent class. The new class that is cloned is called the derived class or inherited class or subclass or child class. The methods that are part of the public and protected access specifiers will be cloned to or inherited to the child class from the parent class. Also we can add new methods or modify the existing method in the child class. The best example we can take is shape. Circle, Square, and triangle are shapes which will have a size, color, position, edges, and lot more. Also we can draw, erase, move and color the shape. Circle, square, and triangle will also have a size, color, position, edges, and also we can draw, erase, move, and color these. Thus Shape is the base class and circle, square, and triangle will be inherited from the shape. This way OOP provides the advantage of code reuse without allowing you to re-write everything from the base. Polymorphism There’s a problem that we have to deal in inheritance. The problem is we attempt to make the derived object type as their generic base type. For example circle as a shape, eagle as a bird, car as a vehicle. I want to draw a circle but because of inheritance it will draw a generic shape. So the compiler doesn’t know at compile time which piece of code will be executed. So when we send a message, the draw method of the circle, or square, or triangle can be executed and thus the proper code is executed based on the specific object type. For example, if the object is circle then the draw method in the circle will be executed. One of the major difference between the non-OOP compiler and the OOP compiler is the way binding happens. In non-OOP compiler, early binding happens. Here during the compilation, the compiler generates a call to the function name and at run time the call will resolved to the address of the code that needs to be executed. But in OOP compiler, you send a message to the object, the code that will executed for this message will not be known until run time. The work of compiler in this case is just to verify if that method we are calling exists for that particular object and checks the type of the arguments and the return value. Java has a special code called absolute call to perform this late binding and this code does all the calculation of the address for the method with the help of the information present in the object. Thus, objects will behave differently based on the content of the special code. This way of doing late binding is called as polymorphism. The exact meaning of polymorphism is the same function will behave differently based on the type of the object it is called. In C++, we use the keyword virtual to say that the particular method is having the late binding property but in Java, by default, the behavior of the method is dynamic binding or late binding and rules out the need for us to remember and add the keyword for making a specific method to have late binding flexibility. Encapsulation Encapsulation is about wrapping the data and the methods that will act on these data into a single unit. Encapsulation is made possible through abstract data type called class. To know about classes and object, please click here. This is just a basic introduction to Java, to learn in-depth from the best tutors in the industry, through our best Java training in Chennai. College to Corporate is the best IT training institute in Chennai.
0 Comments
College To Corporate is the best training in Chennai which provides training in an real time scenarios and trainers are from mnc providing excellent coaching where students can easily interact and learn and become a successful professional For More Information: www.training-in-chennai.com
For More Information Click Here: Software Testing Training in Chennai
Software testing is a process of analyzing a software item to detect the differences between existing and required conditions (that is defects/errors/bugs) and to evaluate the features of the software item. We College To Corporate is the best Software Testing Training in Chennai.
Linux administration is typically associated with the performance of highly technical tasks, tight security, and management of hundreds of users on a large network. We College To Corporate Is the best Linux Admin Training in Chennai. For More Information: www.training-in-chennai.com/
A new version of Microsoft famous Collaboration portal called SharePoint. The version adds few new exciting features such as Social Feed,SharePoint Apps and cross-site publishing.Learn Sharepoint at College To Corporate. For More Information: www.training-in-chennai.com/sharepoint-developer-training-in-chennai.php
About Us: College To corporate, a wonderful software coaching institute started with an intention to produce the most effective coaching in distinctive and emerging technologies for the blossoming Engineers. A bunch of well- toughened IT professionals from high MNC’s have started this institution with an aim to style today’s engineer’s career path as they have dreamt and for a stronger future. MNC’s have hospitable hands for our folks forever and quite one thousand folks trained from our establishment area unit currently operating in leading code firms. we've a good association with well-known MNC’s that offers our folks a kickoff to their calling still as betterment of the current profession. We provide Training on major IT Courses such as Java, J2EE, Web Designing, Digital Marketing, SEO, Software Testing with assured Job Placement. For More Information: www.training-in-chennai.com/ ![]() College To Corporate | Best IT Training Institute: For More Information: www.training-in-chennai.com/ College to Corporate Recent Placement List: For More Information: http://www.training-in-chennai.com/placed-students
College to Corporate Facts:
College to Corporate Offers: For More Information: http://www.training-in-chennai.com/courses/other-training/c-cplus-training
|
Contact us:
|