DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

Understanding String class

String class in Java: A String is a sequence of zero or more characters enclosed in double-quotes. For example,

String name = "Ganga";

The value “Ganga” is called the string literal. We cannot open a double-quote on one line and close the double-quote in another line, they both should be in the same line.

We can embed escape characters (like \t, \n) also in a string literal. For example,

String greetingText = "Hello Thames\nWelcome to London!";

The above line when printed would have “Hello Thames” in one line and “Welcome to London!” in the next line.

We will learn about the String class in detail later.

Select all correct statements.

  • In Java, a String literal can only contain ASCII characters.
  • String text = Hello; is a valid statement.
  • String text = ‘Hello’; is a valid statement.
  • String text = “Hello World”;is a valid statement.
  • String text = “Hello” + “World”;is a valid statement.

Candidates having any kind of query so he/she can ask in our comment section. Our Panel will b reverting back as soon as possible. Thank You. For more details visit our website (https://speedjobalert.com/)

Leave a Comment