--%>

Public class in java

Q. Explain the concept of public classes in java. How they are useful? 

Ans. Public class methods and areas can be accessed from anywhere. But a file with java source code can only contain one public class whose name must also match, with the file name. If it presents, this public class corresponds to the application or the applet in which case the public keyword is essential to allow your web browser or applet viewer to demonstrate the applet.

Use of public classes:  If we want to offer access to these entities and if this access cannot do any harm public class is used.

Example:

Public class square

{    // public class

Public x, y, size;    // public instance variables

}

 

 

   Related Questions in Programming Languages

  • Q : Explain Information hiding Information

    Information hiding: The practice of making sure that only as much information is exposed regarding the implementation of a class as is strictly needed. Hiding needless knowledge of implementation makes it not as much of likely that other classes will

  • Q : How can I get an exact image in a web

    How can I get an exact image in a web page?

  • Q : Explain why java is so important for

    The internet aided java to the forefront of programming. And java consequently has had a deep effect on the internet. The reason for this is highly simple: java uses the universe of objects that can travel freely in cyber space. In a network, two broad categories of

  • Q : Explain Try statement Try statement :

    Try statement: The try statement performs as an exception handler - a position where exception objects are caught and dealt with. In its most common form, it comprises of a try clause, one or more catch clauses and the finally clause.

  • Q : Explain different types of variable iv

    The kind of value that a variable can own is known as data type. When we state a variable we require specifying the type of value it will own with the n

  • Q : Explain Redundant value Redundant value

    Redundant value: The value of a data type which has no use or meaning in a particular context. For example, negative values would be redundant a class employing integer attributes to the model assignment marks. In several applications, redundant patte

  • Q : Use the Processing program for the

    1. Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will print "7", and Bert says, no, when the function exits the changes get reversed and the value goes back to "5". Expl

  • Q : Define the features of DTD Define the

    Define the features of DTD?

  • Q : CORBA allows high performance

    'CORBA was designed to allow high performance distributed applications to be written’. Discuss. Definitely, ’CORBA was designed to allow high performance distributed applications to be written’ because it provides:

  • Q : What are the major issues related with

    What are the major issues related with multiprocessor caches and how might you resolve them?