Introduction to Object Oriented Programming – Java
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.
- By hiding the implementation of the methods and not allowing the client to access this, the class creators can change the implementation whenever necessary without worrying about the impact that will cause on the client programmer.
- By hiding the tender portion of the object from the client programmer, we are avoiding the corruption of the tender portion by the client programmers by mistake or by carelessness.
Now how this is made possible in Java? Java has three keywords public, private, and protected. These are called as access specifiers which determine the visibility of the code.
- Private – No one can access the elements or methods except the class creator or the methods inside the class. Anyone outside the class cannot access these elements or methods. Private is a wall constructed between the methods in the class mentioned as private and the client programmers.
- Protected – It acts like a private with an exception that the inheriting class can access the protected members but not the private members. Inheritance will be introduced to you shortly.
- Public – The elements following the public is accessible by everyone.
The default, which comes by default if you don’t provide any of the specifiers in Java is Private. This private is also called as package access in Java because the members that are private in a class is accessible by other members of the class in the same package but not by the classes outside the package.
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.
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 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.
SOFTWARE TESTING UNIQUENESS:
Software testing is an examination led to furnish partners with data about the nature of the item or administration under test.Software testing can likewise give a goal, free perspective of the product to permit the business to acknowledge and comprehend the dangers of Software usage. Test strategies incorporate the way toward executing a system or application with the plan of discovering Software bugs (blunders or different deformities).
Software testing includes the execution of a product part or framework segment to assess one or more properties of interest. By and large, these properties show the degree to which the part or framework under test:
- meets the prerequisites that guided its outline and improvement,
- reacts effectively to a wide range of information sources,
- plays out its capacities inside a satisfactory time,
- is adequately usable,
- can be introduced and keep running in its planned surroundings, and
- Accomplishes the general result its partners wish.
As the quantity of conceivable tests for even basic Software segments is for all intents and purposes vast, all product testing utilizes some methodology to choose tests that are doable for the accessible time and assets. Accordingly, Software testing ordinarily (yet not solely) endeavors to execute a project or application with the expectation of discovering Software bugs (blunders or different imperfections). The occupation of testing is an iterative procedure as when one bug is settled, it can light up other, more profound bugs, or can even make new ones.
Software testing can give objective, autonomous data about the nature of Software and danger of its inability to clients and/or sponsors.
Software testing can be directed when executable Software (regardless of the possibility that somewhat finish) exists. The general way to deal with Software advancement frequently decides when and how testing is directed. For instance, in a staged procedure, most testing happens after framework necessities have been characterized and afterward executed in testable projects. Conversely, under an Agile methodology, prerequisites, Software, and testing are regularly done simultaneously.Most Probable Software testing tools in Automation is Selenium and also QTP is also being added. Manual Testing can also be done and there are few more software testing tools that are being used they are Load Runner, ETL Testing, Jmeter, Test Complete
Powered by College To Corporate TrainingInstitute
For More Information: http://www.training-in-chennai.com/software-testing-training-in-chennai.php
Inventor of JAVA
James Gosling, is the man who invented java at Sun Labs, around 1992; they had a group which was building a set-top box and cleaned up C++ and then wounded up with the new language and the runtime.
For You to learn JAVA and To Perform With JAVA Click Below:
Java is very mainstream as a Programming Language in the Industry so you can get great open doors, if that is the thing that you are searching for.
You can utilise Java to actualise any sort of Software. It can be an Enterprise Application, a Website, a Desktop application, a Search Engine or a Gadget. You can say this should be possible with any Programming Language, which is entirely valid.
Java is a Secure stage, on account of its Virtual Machine. This is one of the essential reasons Companies worldwide are utilising this Language. So it’s digging in for the long haul.
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 Click Here: 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.
For More Information: http://www.training-in-chennai.com/software-testing-training-in-chennai.php