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 : Interface accessibility modifier Inside

    Inside the interface accessibility modifier we can use for methods?

  • Q : Describe Multiple-boot options

    Multiple-boot options: The hardware configurations of several computers are capable to run various operating system and window manager combinations. A few systems permit a user to select which combination they wish to utilize during a specific session

  • Q : Explain Interpreter Interpreter : A

    Interpreter: A program that executes a translated version of the source program by implementing a virtual machine. The interpreters usually simulate the actions of an idealized Central Processing Unit. An interpreter for Java should implement the Java

  • Q : Explain the term Portable Portable :

    Portable: The Portability is the quality of a program which makes it probable to run it on different kinds of computers. The programs written in low level languages are usually not very portable since they are generally closely tied to a particular in

  • Q : What are ORB-IOR-a servant-a POA manager

    In CORBA, what are i) an ORB ii) an IOR iii) a servant iv) a POA and v) a POA manager?

  • Q : State the term SOAP and explain its

    State the term SOAP and explain its relation with XML.

  • Q : Explain the relationship between XHTML

    Explain the relationship between XHTML and URL?

  • Q : What is an Initializer Initializer : A

    Initializer: A block stated at the outermost level of a class - identical to a method devoid of a header. The initializer blocks are executed, in order, whenever an instance is formed. They are executed prior to the constructor of the defining class,

  • Q : What is Final method Final method :

    Final method: This is a method with the final reserved word in its header. The final method might not be overridden by a method stated in a sub class.

  • Q : What is a Software What is a Software :

    What is a Software: It is a program written to run on the computer.

©TutorsGlobe All rights reserved 2022-2023.