answersLogoWhite

0


Best Answer

In Java, a string constant is a text within double quotation marks. Example:

String playerName = "Player 1"; // Assign a default name initially

Here, the string constant was assigned to variable playerName. If you don't want the value to change later, declare it as final:

final String greeting = "Hello!"

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the examples of string constant?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How string constants are declared in c?

Some strings are constants, others aren't; some constants are strings, other aren't. So these are unrelated things. Examples: "text" -- constant string 123 -- constant number char s[40] -- variable string


How do you close a string literal?

Just as you have started it. good examples: 'string' "string" `string` »string« bad examples: 'string" "string` »string'


What are 2 types of constant in c?

String constants:A string constant is a sequence of alphanumeric characters enclosed in double quotation marks whose maximum length is 256 characters. The following are some examples of valid string constants:1) "The result is ="2) "Test program 123"Numeric constants:Numeric constants are positive or negative numbers. There are four types of numeric constants: integer constant, floating point constant, hex constant and octal constant. An integer constant may either be a short integer or a long integer. A floating point constant may either be of single precision or double precision.


What is literal in c language?

a string constant


What are some example for string formatting in Java?

There are lots of examples of string formatting in Java. It can be difficult at times. Some of these examples are, but are not limited to; align, string, format, and JAVA.


A number or a string of c character is called as?

Constant.


How do you define a constant in PHP?

You can define a constant using the define() directive.you can use this a number of ways;to define a variable to a constant do:$string = "hello";define("string",$string);to define a string to a constant use:define("hello","there");to define a integer or other numerical value use:define("number",1.0);Summery:to define a string use quotes as you would do a string.Unlike variables in PHP a constant cannot be changed or undefined once it is defined. Constant remains automatically globally throughout the script. It means that it can be accessed from inside a function. e.g.


How do you declare a string and character constant?

public static final String WELCOME_MESSAGE = "Hello, welcome to the server";


What is the difference between numeric and string constant?

A numeric constant has a defined numeral value, eg.- 2, 9, 23, 168, etc. A string constant has a defined string value, or a value having english alphabets, eg.- 'A quick brown fox jumps over the lazy dog.'


What is the difference between string type and character type constants?

A character type constant is a character, a char, while a string type is an array of characters. The character type constant is one character and is delimited by single quotes. The string type constant is zero or more characters and is delimited by double quotes.


Does the length of a string have any effect on the reading of the spring scale?

No, the length of the string does not affect the reading of a spring scale. The scale measures the force applied to it, which is not influenced by the length of the string.


What is the role of plus operator between two string constant?

The plus operator between string constants allows string concatination: string a = "Hello, "; string b = "World!"; string c = a + b; The output of c would be: "Hello, World!".