answersLogoWhite

0


Best Answer

Well, it was probably an aesthetic decision on the part of the Java developers, and consider this: The server needs to access some of the applet's attributes, so doesn't it make sense that the applet is public? If the applet was private, nobody would be able to access it.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

Applet class should be declared public so that it can be accessed outside when it is run on browser or thro' appletviewer tool. -Shini Saji

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

so that any one can access it in his program in java.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why user defined applet class declared public?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Are there any difference in the way a class method is defined depending on here it is defined?

Yes, there is a difference in the way a class method is defined depending on where it is declared.


Abstract class can be private?

A class can either be default or public it can never be declared as private, so the question of abstract class at the file level does not arise. But an inner class can be declared private and abstract as well.


Write a program to create an applet with red back ground and display the message welcome to the world of applets write its HTML document also specify width and height to the applet?

import java.applet.Applet; import java.awt.Graphics; @SuppressWarnings("serial") public class AppletTest extends Applet { public void paint (Graphics g) { g.drawString("WELCOME TO THE WORLD OF APPLETS", 100, 25); setBackground(java.awt.Color.RED); } } <HTML> <HEAD> <TITLE> AppletTest</TITLE> <BODY> <CENTER> <APPLET CODE = "AppletTest.class" WIDTH = 400 HEIGHT = 100 </APPLET> </CENTER> </BODY> </HEAD> <HTML>


Write a program to show the applet life cycle?

/*Applet Life Cycle ExampleThis java example explains the life cycle of Java applet.*/import java.applet.Applet;import java.awt.Graphics;/*** Applet can either run by browser or appletviewer application.* Define tag within comments as given below to speed up* the testing.*//**/public class AppletLifeCycleExample extends Applet{/** init method is called first.* It is used to initialize variables and called only once.*/public void init() {super.init();}/** start method is the second method to be called. start method is* called every time the applet has been stopped.*/public void start() {super.start();}/** stop method is called when the the user navigates away from* html page containing the applet.*/public void stop() {super.stop();}/* paint method is called every time applet has to redraw its* output.*/public void paint(Graphics g) {super.paint(g);}/** destroy method is called when browser completely removes* the applet from memeory. It should free any resources initialized* during the init method.*/public void destroy() {super.destroy();}}


How do you run applet program?

By Embedding it into a HTML page, create a new file with the extension .html (like app.html) insert following code: No Java 2 SDK, Standard Edition v 1.4.2 support for APPLET!! Adjust the code for your applet file (can't help there i am not a java programmer) or just use : No Java 2 SDK, Standard Edition v 1.4.2 support for APPLET!! but i recommend the first because the applet tag is deprecated and not supported in XHTML

Related questions

Are there any difference in the way a class method is defined depending on here it is defined?

Yes, there is a difference in the way a class method is defined depending on where it is declared.


When an applet become an applet?

Any Java class that extends java.applet.Applet is an applet. http://java.sun.com/j2se/1.5.0/docs/api/java/applet/Applet.html


What is the file extension of an applet?

An applet is a Java application, this saves files in a .class extension


How a class in java declared default?

default it is public type


What is public private protected variable function?

The public, protected and private keywords only apply to object oriented programming languages. They are used to determine the accessibility of specific class members and their bases. Private members are only accessible to the class and to friends of the class. Protected members are the same as private but are also accessible to derivatives of the class. Public members are accessible to all code. When applied to base classes, the public, protected and private keywords can be used to either maintain or reduce the accessibility of the base class members (but never to increase their accessibility). When declared public, the accessibility of the base class members remains as defined by the base class. When declared protected, the public members become protected members. And when declared private, all members of the base class become private members. As well as defining the overall accessibility of the base class members, the accessibility of individual base class members can also be specified.


Abstract class can be private?

A class can either be default or public it can never be declared as private, so the question of abstract class at the file level does not arise. But an inner class can be declared private and abstract as well.


Write a program to create an applet with red back ground and display the message welcome to the world of applets write its HTML document also specify width and height to the applet?

import java.applet.Applet; import java.awt.Graphics; @SuppressWarnings("serial") public class AppletTest extends Applet { public void paint (Graphics g) { g.drawString("WELCOME TO THE WORLD OF APPLETS", 100, 25); setBackground(java.awt.Color.RED); } } <HTML> <HEAD> <TITLE> AppletTest</TITLE> <BODY> <CENTER> <APPLET CODE = "AppletTest.class" WIDTH = 400 HEIGHT = 100 </APPLET> </CENTER> </BODY> </HEAD> <HTML>


Write a program to show the applet life cycle?

/*Applet Life Cycle ExampleThis java example explains the life cycle of Java applet.*/import java.applet.Applet;import java.awt.Graphics;/*** Applet can either run by browser or appletviewer application.* Define tag within comments as given below to speed up* the testing.*//**/public class AppletLifeCycleExample extends Applet{/** init method is called first.* It is used to initialize variables and called only once.*/public void init() {super.init();}/** start method is the second method to be called. start method is* called every time the applet has been stopped.*/public void start() {super.start();}/** stop method is called when the the user navigates away from* html page containing the applet.*/public void stop() {super.stop();}/* paint method is called every time applet has to redraw its* output.*/public void paint(Graphics g) {super.paint(g);}/** destroy method is called when browser completely removes* the applet from memeory. It should free any resources initialized* during the init method.*/public void destroy() {super.destroy();}}


Applet class is not inheriting AppletContext interface but in Applet Class getAppletContext method is returning AppletContext object how is it possible?

There's nothing in Java that says that a method in a class can only return object types that the class inherits from. Your Applet is running in some sort of environment (a context, if you will). The Applet.getAppletContext method returns an AppletContext object which describes this environment.


How do you run applet program?

By Embedding it into a HTML page, create a new file with the extension .html (like app.html) insert following code: No Java 2 SDK, Standard Edition v 1.4.2 support for APPLET!! Adjust the code for your applet file (can't help there i am not a java programmer) or just use : No Java 2 SDK, Standard Edition v 1.4.2 support for APPLET!! but i recommend the first because the applet tag is deprecated and not supported in XHTML


Can you run applet on web-browsers?

Yes. Java's Applet class was made specifically to be embedded within a web browser window.


What are shared classes in net?

Publicly defined classes eg, "Public class"