Skip to main content

Chapter 5 What is Syntax of Java/ Keywords/ Comments Explain in Details.

 Syntax Of Java Program :- 

What is Syntax:- It is a code of word excited rule of Program then say at last it is a format of Program

.


class Easy {
            public static void main(String[] args) {
                System.out.println("Hello World");
            }
        }


 

 class

1.It is a keyword which is used to declare a class.

2.Keyword:The word which is predefined in the library is called keyword.

for example class, void, main etc.

Easy

1.It is an user defined class name.

 

public

1.It is a keyword which is called access specifier/modifier.

2.It is used to provide accessibility of data member(variable) and member function.

 

static

1.It is a keyword.

2.It can be used with a variable or function or block, we will discuss it in next chapter.

 

 

Void

1.It is a keyword.

2.It indicates that there is no value is returning by the function.

3.If we use any other keyword like int, float, char etc,  in place of void then we will use return keyword.

 

 

main()

1.It is the function which is called the entry point of any program.

2.The execution of any program starts from the main function.

3.If in a program there is only one function then it should be main function.

 

String[]args

1.It is an array of type String.

2.It is also called command line argument.

3.you can write anything in place of args

 

System.out.println()

or print, printf()

1.It is used to print data or information on to the output screen.

2.System.out means Standard output object.

3.println is a method/function.

 I think follow this table explain hope your doubts your clear.

Keywords in Java 

  • The keyword which is pre-defined in the library is called keyword. It's functionality is also pre-defined.
  • Keyword can not be used as a varible,  function_name, class_name or as any identifier. 
  • Example of Keywords are int, float, char, void, main etc.

List of Keywords  in Java 

Char

Continue

Catch

Finally

Int

Default

Interface

Class

Float

Assert

Abstract

Const

Double

Abstract

Public

Protected

Long

Implements

Bytes

Case

Short

Private

Native

Goto

If

Break

Volatile

New

Else

Enum

Synchronized

Static

Do

Import

Switch

This

While

Strictfp

Transient

Try

For

super

Throws

Final

Instanceof

Extends

Boolean

Pakage

Return

Void

 

 


Comments in Java 
  • It is used to explain the code to make it more readable.
  • It is not considered as a part of program. 
  • In other word we can say that compiler ignores the comments.
  • Java comments are statements that are not executed by the compiler.
Types of comments in Java
  • Single line comment
  • Multiline comments

Single line comment :- 
  • It is used to comment only one line.
  • Two forward slashes(//) is used for single line comment.
  • Single line comment starts with double forward slashes.
//this is a single line comment
System.out.println("you are excellent");



Multi line comments:- 
  • Multiline comment is used to comment a block of code.
  • Multiline comment statrts with /* and ends with */.
  • The text between /* and */ is not executed by the compiler.
  • An Example of Program 
        class Easy {
            public static void main(String[] args) {
/*
This is multiline comment
Write a program to add
two number and store it
in third number
*/
        int x, y = 10, z = 30;
                x = y + z;
                System.out.println("Add=" + x);
            }
        }
        /*
        Output is:
        Add=40
        */


Comments

Popular posts from this blog

Assignment of ITA/ Information Technology and Application BCA- Technology369kk

Q1. What is  computer Explain basic computer architecture and Difference components.  2. Discuss the use of memory in computer system, Explain memory hierarchy  in details. 3. What is software? Explain difference types of software with explain. 4. Write short notes on the given:- (I) Internet. (II) LAN (Local area network ) (III) Search engine (IV) Web browser  Q 1.What is computer Explain basic computer architecture, Difference components of computer.   Computer :- Computer is defined as an electronic device that takes input data and instructions from the user and after processing them, it generates useful and desired output quickly.   A computer is designed to execute applications and provides a variety of solutions through integrated hardware and software components.                            It is fast and automatic device. It works with the help of programs and represents the d...

C++ and Java Practical All Questions Answers - BCA -Technology369kk

C++ and Java  In this post see most important questions for practical questions given by college all questions with answers . Guys I want to say that this is only for suggested post for your practical please request to you change same alphabets, words or anything  methods name and variables name because if you write all words same then this is copy paste for another peoples.  Used Topics:  Keywords, Variables, Condition Statements, Function , Array, Structure, Pointer.                           In OOPs, Class and Objects, Constructor, Poly morph, Encapsulation, Access Specifiers,                               Inheritance etc.  So, Without Time Lose Come to the Points, let's go start Now:        *************************************************************************  C++ 12 ...

Assignment of PMO (Principal of Management and Organization) - Technology369kk

 ** Assignment Of PMO ** Agenda: -  4 Questions discuss in this post. Question 1. Write a d etails note on selection why it Called. negative process.  Question 2. Write a details note on 'span of control. Question 3. Planning is an essential process, do you agree ? Discuss  Question 4. Write a note on management function. Q 1. Write a d etails note on selection why it called negative process.  Ans :-  Selection is the process of choosing the most suitable candidates out of the several candidates available.          Selection is a negative process because there may be more rejected then those selected in most of the candidates that is called selection is a negative process. → Selection process has the following steps:-  [ A .] Screening of applicants - Based on the screening of applicants only those candidates. It Called further process of selection. Who are found eligible for the job Standards of the the organization. [ B .] S...