6 WEEKS TRAINING

We provide 6 weeks industrial training in Java and Android to B.Tech, B.E. engineering graduates.

6 MONTHS TRAINING

We provide 6 Months live project based industrial training in Java and Android to B.Tech, B.E., MCA, BCA students.

CORPORATE TRAINING

We provide customized and cost effective corporate training in Java, Spring, Hibernate, Web Services, Android, and Angular JS.

Assignment 5: Use of Strings in Java

  • 10 questions Complexity: Medium

Define another class named Test1 which contains main() method. In the main() method, 3 MyString objects are created, their values and length are displayed as output.

Let the MyString objects be initialized by byte b[]= {65,66,67,68,69,70}, char c[]={'x','y','z'} and "Java" respectively.

java Test1 ↵

First String is: ABCDEF and its length is: 6.
Second String is: xyz and its length is: 3.
Third String is: Java and its length is: 4.

Define another class named Test2 which contains main() method. In the main() method, 3 MyString objects are created, first String is compared with the other two using equals() method and the result is displayed as output.

Let the MyString objects be initialized by byte b[]= {65,66,67}, char c[]={'x','y','z'} and "ABC" respectively.

java Test2 ↵

str1.equals(str2): false
str1.equals(str3): true

Define another class named Test3 which contains main() method. In the main() method, 3 MyString objects are created, displayed in their alphabetical order with the help of compareTo() method.

Let the MyString objects be initialized by byte b[]= {70,71,72}, char c[]={'P','Q','R'} and "ABC" respectively.

java Test3 ↵

Strings in alphabetical order : ABC, FGH, PQR

Define another class named Test4 which contains main() method. In the main() method, 2 MyString objects are created, their values are displayed, second string is concatenated to the first and the concatenated String is displayed.

Let the MyString objects be initialized by "Hello" and "India" respectively.

java Test4 ↵

First String: Hello
Second String: India
Concatenated String: HelloIndia

Define another class named Test5 which contains main() method. In the main() method, a MyString object is created, displayed, and a substring is extracted from it and is displayed.

Let the MyString object be initialized by "HelloIndia".

java Test5 ↵

Main String: HelloIndia
Substring from 5 to 9 index: India

Define another class named Test6 which contains main() method. In the main() method, a MyString object is created, displayed, and its substring is replaced by a given string and the result MyString object is displayed.

Let the MyString object be initialized by "HelloIndia".

java Test6 ↵

Main String: HelloIndia
String obtained after replacing Hello by Welcome To : Welcome To India

Define another class named Test7 which contains main() method. In the main() method, a MyString object is created, displayed, and some strings are searched in it with the help of contains() method. Result of the search is displayed as output.

Let the MyString object be initialized by "HelloIndia".

java Test7 ↵

Main String: HelloIndia
Searching India in it: Found.
Searching She in it: Not Found.

Define another class named Test8 which contains main() method. In the main() method, a MyString object is created, is displayed, and the last index of "are" is obtained and displayed as output.

Let the MyString object be initialized by "Though they are brutal yet they are caring".

java Test8 ↵

Main String: Though they are brutal yet they are caring
The last index of are in the string is: 32.

Define another class named Test9 which contains main() method. In the main() method, a MyString object is created, displayed, its words are extracted and displayed as output.

Let the MyString object be initialized by "To err is human.".

java Test9 ↵

Main String: To err is human.
Individual words:
To
err
is
human.

Define another class named Test10 which contains main() method. In the main() method, a MyString object is created, displayed, its case is changed to upper casee and the changed string is displayed.

Let the MyString object be initialized by "Hello World".

java Test10 ↵

Main String: Hello World
String after case change: HELLO WORLD.

For queries:  8130-311-892,  9212-468-649

ONE YEAR VALIDITY

Admission is valid for one year i.e students can revise the course any number of times if popular fee plan is opted.

INDUSTRIAL TRAINING CERTIFICATION

Industrial training and course certificates are provided after the successful completion of each course.

PLACEMENT ASSISTANCE

We provide 100% placement assistance to all the students on the basis of monthly assessment tests.