Question: What is String in JAVA ?
Ans: Java me, "String" ek data type hota hai jo text ko represent karta hai. String ek sequence of characters hoti hai, jaise ki alphabets, numbers, symbols, aur special characters. Java me, String class predefined hoti hai, aur aap iska istemal karke text data ko store, manipulate, aur access kar sakte hain.
Strings are non Primitive Data Type.
Question: What is .length(); ?
Ans: this is to check length of a String .
Question: Different between single quote and double quote in String .
Ans: Single quote ' ' ['D'] is basically used to store character but double quote is used to store " " ["Divyanshu"] a string basically sequence of character .
Question: How to add, concat a string ?
Ans : There is two way to concat or add a string
1) first is to use Addition (+) arithemetic operator
2) .concat
package learningJava;
import java.util.*;
public class regPract {
/* Find the maximum and minimum element in an array
*/
public static void main(String[] args) {
String str1 = ("Digital");
String str2 = ("India");
*\this is method of java concat is a method of java two concatenate string*/
String str = str1.concat(str2);
System.out.println(str);
//this is general option to add a string
System.out.println(str1+str2);
}
}
Output:DigitalIndia
DigitalIndia
Question: What is .equals in String ?
Ans: str1.equals(str2); This is for check 2 strings are qual or not and it will give you boolean result like true and false
Question: What is .compareTo method in java ?
Ans: String str1 = "apple";
}
This will compare two strings
Question: What is equalsIgnoreCase is java ?
Ans: The equalsIgnoreCase method is a Java String class method used to compare two strings for equality while ignoring the differences in their letter case (uppercase or lowercase). It checks if two strings have the same characters, regardless of whether the characters are in uppercase or lowercase.
String is a class
Question: How many types of class available on java to create String class ?
Ans: There're 3 classes available here to create a String class
1) String
2) String buffer
3) String builder
Question: How to use concat is JAVA ?
Ans:
package learningJava;
import java.util.*;
public class regPract {
/* Find the maximum and minimum element in an array
*/
public static void main(String[] args) {
String str = "Divyanshu";
str = str.concat("khare");
System.out.println(str);
}
}
Question: contains what is this ?
Comments
Post a Comment