Invoking an Applet: - Mithun Jadhav | Connecting
Structured LanguagesData types of Functions, PointersCharacteristics of OOPSoln. Principle concepts of OOPs are:AbstractionEncapsulationInheritancePolymorphismAbstraction is the process of identifying the key aspects of an entity and ignoring the rest. Only those aspects are selected that are important to the current problem scenario. For eg. Consider a person object, the abstraction of this object would be different in different problem domains.As demonstrated in the table below, a person would be abstracted in different ways in 3 different problem domains:Social SurveyHealth CareEmploymentNameNameNameAgeAgeAgeMarital Status--Religion--Income Group--AddressAddressAddressOccupationOccupationOccupation-Blood Group--Weight--Previous Record---Qualification--Department Encapsulation is a mechanism used to hide the data, internal structure and implementation details of an object. All interaction with the object is through a public interface of operations.The user knows only about the interface, any changes to the implementation doesnot affect the user. For eg. The internal components of a television and working are hidden from the end user. TV has a set of buttons either on the TV or remote which acts as an interface to operate the TV. Data hiding ensures security. Encapsulation separates interface of an abstraction and its implementation. One advantage is that even if the method/function implementation is changed, the user need not know about it as long as the interface (calling mechanism) remains same.Inheritance is a mechanism by which a new class is derived from an existing one. It not only helps to reuse the old code but aids in extending the software. Inheritance is similar to parent-child relationship. In inheritance each child has an ‘is-a’ relationship with its parents. The new class which is being created is called as derived class and the class from which it is derived is called as a base class. With the help of inheritance a hierarchy of classes is created.Generalization and specialization are two points of view that are based on class hierarchies. They express the direction in which the hierarchy is extended.Generalization: Moving up in the hierarchy is called as generalization. Factoring out common elements within a set of categories into a more general category called super-class. Requires good skills of abstraction.Specialization: While moving down the hierarchy more and more specific features are added in each sub category that is formed. This is said to be specialization. Allows to capture specific features of a se of objects.Features of Inheritance:Object oriented programming extends abstract data types to allow for type/subtype relationships. It is achieved through inheritanceTo inherit means to recieve properties of an already exisitng classWhen an existing class is inheritted, the derived class inherits all data members as well as the member methods from base class. But not all of them can be accessed by member methods of deived class. The accessibility of base class members in the derived class depends on their access specifiers.Advantages of inheritance:Reusability: Once a class is written and tested, it can be further used for creating new classes. These derived classes not only inherit the features of their base class, but also have their own individualistic features. This means that if the derived class wants to use its base class properties it can do so because these properties are also available to the derived class by virtue of inheritance.Extensibility: It is the mechanism of being able to derive classes from existing classes. This provides extensibility of adding and removing classes in a hierarchy as and when required.Polymorphism is the ability of different types of related objects to respond to the same message in their own ways. The word “polymorphism” is combined from two words, “poly” means many and “morph” is a form. Thus polymorphism is the ability to take more than one form. Polymorphism plays an important role is allowing different objects to share the same external interface although the implementation may be different. Polymorphism a static one or dynamic one dependending on process of associating a function call to an object.Static polymorphism: It is achieved using early binding. When binding occurs at compile time, it is known as early binding. The argument passed to the method decides the method to be invoked at compile time. Early binding is achieved using method overloading.Dynamic polymorphism: It is achieved using late binding. When binding process occurs at run time, it is called late binding. The appropriate method is invoked at run time by checking type of an object. Late binding is achieved using method overriding.Constructors and Destructors(with access specifiers)Inheritance : from soln3Java provides access control modifiers to support the intermediate level of implementation hiding. By applying proper modifiers on class fields and methods, the class’s implementation can be hidden from classes outside the package while exposing the implementation to the classes inside the package. Java provides following four access spcifiers:private: The private modifier restricts access of members of a class, so that no other classes can call member functions or directly access member variables.protected: A protected member gives preffered access for subclasses in other packagespublic : Members and variables declared public can be accessed by everyone ie. Code from any class.Default : Package access, denoted by no access control modifier keywords. Field or method accessible to any type in the same package.Access modifierAccessibility in subclassAccessibility in other classSame packageDifferent packageSame package Different packagePrivateNoNoNoNoPublicYesYesYesYesProtectedYesYesYesNodefaultYesNoYesNoPolymorphismFrom soln3Derived and base classes ClassA class with atleast one method that has no implementation is called as an abstract class. Other methods can be abstract or non abstract. By design, objects of abstract class cannot be created, but references can be created. So it is the responsibility of the developer to implement the abstract method in the derived class. Abstract class is defined using abstract keyword. The abstract keyword enables creation of classes and class members solely for the purpose of inheritance – to define the common features of derived classes. Using abstract class, a hierarchy can be created that is easily extensible.abstract class Shape{ public abstract void area();}public class Circle extends Shape{int radius;//.. other codepublic void area(){//code to find area of the circle}}public class Rectangle extends Shape{int length, bredth;//.. other code; public void area(){//code for finding the area of rectangle}}In the above example, the base class has one abstract method area() making it an abstract base class. The method has been implemented by its derived classes – Circle and Rectangle.Following points should be noted regarding abstract classes:One cannot create objects of abstract classes. Any attempt to do so, results in compile time error.One can create references and therefore these classes support polymorphism.Abstract classes are useful when creating components because they allow specifying an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class in needed.Abstract methods dont have implementationA class inheriting from an abstract class must provide implementation to all abstract methods, else the class should be declared as abstract.Static modifiers cannot be used with abstract methods.Abstract modifiers cannot be used with constructorsPure virtual functions, public and protectedFrom soln5Characteristics of JAVA programming Handling Multithreading and JAVA applets applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its disposal.There are some important differences between an applet and a standalone Java application, including the following: An applet is a Java class that extends the java.applet.Applet class. A main() method is not invoked on an applet, and an applet class will not define main(). Applets are designed to be embedded within an HTML page. When a user views an HTML page that contains an applet, the code for the applet is downloaded to the user's machine. A JVM is required to view an applet. The JVM can be either a plug-in of the Web browser or a separate runtime environment. The JVM on the user's machine creates an instance of the applet class and invokes various methods during the applet's lifetime. Applets have strict security rules that are enforced by the Web browser. The security of an applet is often referred to as sandbox security, comparing the applet to a child playing in a sandbox with various rules that must be followed. Other classes that the applet needs can be downloaded in a single Java Archive (JAR) file.Life Cycle of an Applet:Four methods in the Applet class give you the framework on which you build any serious applet:init:?This method is intended for whatever initialization is needed for your applet. It is called after the param tags inside the applet tag have been processed.start:?This method is automatically called after the browser calls the init method. It is also called whenever the user returns to the page containing the applet after having gone off to other pages.stop:?This method is automatically called when the user moves off the page on which the applet sits. It can, therefore, be called repeatedly in the same applet.destroy:?This method is only called when the browser shuts down normally. Because applets are meant to live on an HTML page, you should not normally leave resources behind after a user leaves the page that contains the applet.paint:?Invoked immediately after the start() method, and also any time the applet needs to repaint itself in the browser. The paint() method is actually inherited from the java.awt.A "Hello, World" Applet:The following is a simple applet named HelloWorldApplet.java:import java.applet.*;import java.awt.*;public class HelloWorldApplet extends Applet{ public void paint (Graphics g) { g.drawString ("Hello World", 25, 50); }}Invoking an Applet:An applet may be invoked by embedding directives in an HTML file and viewing the file through an applet viewer or Java-enabled browser.The <applet> tag is the basis for embedding an applet in an HTML file. Below is an example that invokes the "Hello, World" applet:<html><title>The Hello, World Applet</title><hr><applet code="HelloWorldApplet.class" width="320" height="120">If your browser was Java-enabled, a "Hello, World"message would appear here.</applet><hr></html>Networking and Security – role of JAVA. components Decomposition ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- ibm rational projectconsole hands on workshop
- invoking an applet mithun jadhav connecting
- overview temple university
- cop2210 programming i
- using the bluej debugger
- machine learning workshop
- faa java aviation paid weather observation report
- jdop 2 a platform for java based distributed object
- vista scheduling enhancements technical manual
- dlrl cluster final
Related searches
- connecting passage crossword
- outlook 2016 not connecting to office 365
- piston and connecting rod assembly
- macbook not connecting to bluetooth
- connecting the concepts protein structure and function
- outlook not connecting to exchange
- connecting batteries in parallel
- windows 10 connecting to another computer
- email not connecting to server
- cognitive psychology connecting mind
- windows 10 problem connecting to the internet
- 12 7 detroit connecting rod install