0 like 0 dislike
5 views
asked in Biology by (474k points)
What is constant? Explain different types of constants.

1 Answer

0 like 0 dislike
answered by (474k points)
Constants :- Constants in java are fixed values those are not changed during the Execution of program java supports several types of Constants  those are  

1) Integer Constants:-  Integer Constants refers to a Sequence of digits which Includes only negative or positive Values and many other things those are as follows

  An Integer Constant must have at Least one Digit

  it must not have a Decimal value

  it could be either positive or Negative

  if no sign is Specified then it should be treated as Positive

 No Spaces and Commas are allowed in Name

2) Real Constants :-  

A Real  Constant must have at Least one Digit

it must  have a Decimal value

it could be either positive or Negative

if no sign is Specified then it should be treated as Positive

No Spaces and Commas are allowed in Name

Like 251, 234.890 etc are Real Constants

In The Exponential Form of Representation the Real Constant is Represented in the two Parts The part before appearing e is called mantissa whereas the part following e is called Exponent.

 In Real Constant The Mantissa and Exponent Part should be Separated by letter e

 The Mantissa Part have may have either positive or Negative Sign

 Default Sign is Positive

Single Character Constants:-  

A Character is Single Alphabet a single digit or a Single Symbol that is enclosed within Single inverted commas.

Like ‘S’ ,’1’ etc are Single  Character Constants

String Constants:-  String is a Sequence of Characters Enclosed between double Quotes These Characters may be digits ,Alphabets  Like “Hello” , “1234” etc.

Backslash Character Constants:- Java Also Supports Backslash Constants those are used in output methods For Example \n is used for new line Character These are also Called as escape Sequence or backslash character Constants For Ex:
Welcome to Free Homework Help, where you can ask questions and receive answers from other members of the community. Anybody can ask a question. Anybody can answer. The best answers are voted up and rise to the top. Join them; it only takes a minute:

10.2k questions

9.2k answers

40 comments

3.2k users

Categories

Free Hit Counters
...