Computer Science, asked by Ran72648, 11 months ago

what is the basic format of Java program explain with an example​

Answers

Answered by prabhushankar1771
27

Answer:

. Format of a Java program

Java programs we'll be writing early in CS 61B each consist of class definitions. A definition provides the name of the class and, you'll recall from CS 61A, its variables and methods. In Java, a class definition starts with the word "class" (possibly preceded by the word "public" or "private"), continues with the name of the class and the character "{" (a left brace or curly bracket), and ends with the character "}" (a right brace). Inside the braces are definitions of methods and variables.

A method definition similarly starts with naming information followed by a pair of braces that include the statements of the method. The braces act in this way like parentheses in Scheme. Braces appear inside methods as well, to group statements (again in the same way that statements in a Scheme procedure body are grouped with parentheses). Statements within such a group are separated with semicolons. Here's an example of a "Hello world" program in Java (traditionally, the simplest program in a given language):

Answered by ajaymadhusingh4
38

Java program has first statement as Java package statement one Java file can have multiple classes declared in it but only one public class which should be same as filename Java class have instance such as method and instance variables

thank you hope I helped

please also follow me

Similar questions