• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Public and Private Keywords

April 4, 2012 by ProjectsGeek Leave a Comment

Public and Private Keywords Java
The public keyword is an access specifier.
Determines how the other parts of the program can access the members of the class.
When a class member is preceded by public, then that member can be access by code outside the class in which it is declared. 

The opposite of public is private.
Prevents a member from being used by code defined outside of its class.

In our program, main() must be declared as public since it must be called by code outside of its class when the program is started.

The keyword static allows main() to be called before an object of the class has been created.
This is necessary since main() is called before an object of the class has been created.

The keyword void tells the compiler that main() does not return a value.
Methods may also return values.

As stated, main() is the method called when a Java application begins.

Any information that you need to pass to a method is received by variables specified within the set of parentheses that follow the name of the method.
These variables are called parameters.
If no parameters are required for a given method, you still need to include the empty parentheses.

The next line
System.out.println (“Java Language”);
Outputs the string “Java Language” followed by  a new line on the screen.

Output is accomplished by the built-in println( ) method.
println( ) displays the string which is passed to it. println( ) can be used to display other types of information as well.

The line begins with System.out.
System is a pre-defined class that provides access to the system out is the output stream that is connected to the console.

System.out is an object that encapsulates console output.
Console input and output is not used frequently in real-world Java programs and applets. Since most application are windowed and graphical in nature, console I/O is used for simple utility programs and demonstration programs.

All statements in Java end with a semicolon.
Notice that the println( ) statement ends with a semicolon.

Java is case sensitive.
If you accidentally type Main instead of main, the program will be incorrect.
Although the Java compiler will compile classes that do not contain a main() method, it has no way to execute them.

 

Public and Private Keywords 3

Other Projects to Try:

  1. Java Programs
  2. First Program in Java
  3. Threads in Java Tutorial for Beginners
  4. Socket programming in Java
  5. Declaring Classes in TypeScript Angular 2

Filed Under: Java Projects Tagged With: Java Projects

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy