answersLogoWhite

0


Best Answer

Symbolic constants are named constants

like :

final double PI = 3.14 ;

They are constants because of the 'final' keywords, so they canNOT be reassigned a new value after being declared as final

And they are symbolic , because they have a name

A NON symbolic constant is like the value of '2' in expression

int foo = 2 * 3

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

java do not support the constants like C but contains "static final"

the sample code in bellow.

note1 : the variable definition is in the class scope.

note2 : standard naming in java says that the final type is ALL CAPS.

file name : Class2.java

----------------

package mypackage1;

public class Class2

{

public static final double PI = 3.14;

public static void main(String[] args)

{

pi++; // thi is the wrong operation; there should be ni operation on final type

System.out.println(PI);

System.out.println(PI+1); // this will work, but for crazy programmers only ;D

}

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

final int variable;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you declare symbolic constants in Java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is symbolic constants?

Symbolic constants are constants that the programmer has decided to give a symbolic name (usually one with a meaning to make it easy to remember) so he does not have to retype the numeric value every time he needs it and risk making an error. Many coding standards require ALL constants to be symbolic constants, even if only used once in the program.


What are symbolic constants?

A symbolic constant is a constant with a name, numeric constants are unnamed and must be retyped in the code on each usage. Generally use of symbolic constants is preferred as it makes the code self documenting and allows the compiler to catch typing errors in constant usage.


What is the definition of symbolic constants in c language?

constants are values that does not chnage through out the program exceution..


What kind of constructs can be declared in a Java interface?

Constants and abstract methods. That's it.


What is the symbolic form made up of constants variables and operations?

It is an expression.


What keyword is used to declare a named constant?

Constant in Java refers to a fixed value that doesn’t change during the execution of a program. The value of constants appears right in a program. It is also known as Literals. We use the constants to create values that assign to variables. Constants can make our program easy to read and understood by others. Java does not directly support the constant. To define a variable as a constant, We use the “Static” and “Final” Keywords before declaring a variable. Hope this helps. Thank you


What happen if you declare class as recursive?

It will get a compiler error in Java.


How do you prevent extending a class in java?

You can declare a class as "final".


What are the 'Constants' and 'Variables' in Java?

A variable is a memory address that holds a value. A constant is simply a variable that does not change value.


What do mean by interface in java?

An interface in Java is like an abstract class, but there are no method bodies allowed in it and it has to be declared with the interface keyword. It is Java's way of getting around the Deadly Diamond of Death. Only abstract methods and constants are allowed in it.


What is a symbolic constant in c language?

symbolic constants are constants represented by symbols.... constants are values that does not change through out the program execution. e.g #include<stdio.h> #include<conio.h> #define NUM 15 void main() { int a=NUM; printf("The constant is %d",a); getch(); } here #define is a preprocessor. its job is to replace all the entries named NUM as 15. So that the compiler works with the constant 15...


How do you prevent class extending in java?

Declare the class as final. final class A{ ... }