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 : Distinct features of Object oriented

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

    Q : Define Class Class : It is a

    Class: It is a programming language concept which permits data and techniques to be grouped altogether. The class concept is basic to the notion of an object-oriented programming language. Methods of a class define the set of permitte

  • Q : What is Namespace Namespace: It is the

    Namespace: It is the region of a program in which specific identifiers are visible. Java employs packages to give namespaces, and its visibility rules: package, private, protected, public-variously include identifiers within the namespaces.

  • Q : Explain the term an XHTML element

    Explain the term an XHTML element attribute.

  • Q : Write a program that initializes an

    Write a program that initializes an integer array a[20] with values {0, 1, 2, 3, ...18, 19 - once each} then scrambles them up and prints the values in random order. For example: 19 2 3 8 11 1 4 17 7 15 9 0 16 12 18 13 5 6 10 14    

  • Q : State the term XLL State the term XLL?

    State the term XLL? Answer: The specification of XML Link Language has XPointer or XLink.

  • Q : Define Multiple Inheritance Multiple

    Multiple Inheritance: In C++, multiple-inheritance occurs when a class inherits from more than one parent. For example: 524_mult</span></p>
                                        </div>
                                        <!-- /comment-box -->
                                    </li>
   
   </td>
	</tr><tr>
		<td>
       
      <li>
                                        <div class=

    Q : How is an XPointer processor configured

    How is an XPointer processor configured?

  • Q : Explain Throws clause Throws clause :

    Throws clause: It is a clause in a method header pointing that one or additional exceptions will be propagated from this technique. For example:    public int find(String s) throws NotFoundExc

  • Q : State Null character State Null

    State Null character: The \u0000 character. The care must be taken not to confuse this with null reference.

©TutorsGlobe All rights reserved 2022-2023.