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 : What is Leverage Model-Based Design

    Leverage Model-Based Design: Model-based design provides useful hints of how a large system can be reduced so that its state space becomes searchable. If not inherently visible in the design (for example, by means of using a “State” design

  • Q : Explain the difference between a

    Explain the difference between a computer process and thread.

  • Q : Define Implements clause Implements

    Implements clause: That part of a class header which points out which interfaces are applied by the class. A class might implement for more than one interface.

  • Q : Explain Decrement operator Decrement

    Decrement operator: It is an operator (--) which adds one to its operand. This has two forms: pre-decrement (--x) and post-decrement (x--). In its pre-decrement form, the outcome of the expression is the value of its argument subsequent to the decreme

  • Q : What is an Anonymous array Anonymous

    Anonymous array: It is an array formed without an identifier. The anonymous array is generally formed as an actual argument, for example:// generate an anonymous array of integers.    YearlyRainfall y2k = new YearlyRai

  • Q : Define the term Key value Define the

    Define the term Key value: The object employed to produce an associated hash code for look-up in an associative data structure.

  • Q : Define the term XSL-FO Define the term

    Define the term XSL-FO. Answr: A sub-element of XSL used for explaining font sizes, how information flows from one page to other and page layouts.

  • Q : Explain Swing Swing : The Swing classes

    Swing: The Swing classes are portion of a wider collection termed as the Java Foundation Classes (abbreviated as JFC). The swing classes are stated in the javax.swing packages. They give a further set of components which extend the capabilities of Abs

  • Q : State the term INODE State the term

    State the term INODE. Answer: It is a pointer to a block upon the disk and is a unique number. This holds metadata of files.

  • Q : Distinct features of Object oriented

    Q. What are the distinct features of Object oriented programming language?  

    Discover Q & A

    Leading Solution Library
    Avail More Than 1434894 Solved problems, classrooms assignments, textbook's solutions, for quick Downloads
    No hassle, Instant Access
    Start Discovering

    18,76,764

    1946427
    Asked

    3,689

    Active Tutors

    1434894

    Questions
    Answered

    Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!

    Submit Assignment

    ©TutorsGlobe All rights reserved 2022-2023.