Description
Topic: String Handling ASSIGNMENT 7
Exercise 1.1: Practice string methods
Write a java program to perform string methods by considering the given string inputs
String s1=”Welcome to Java”;
String s2=s1;
String s3=new String(“Welcome to Java”);
String s4=s1.intern();
Exercise 1.2: Write a program to show that String is immutable in java Exercise 2: String reverse
Write a java program to read the string and displays the reverse of the string.
Hint: swap first character with last character until half of the string length
Exercise 3: Letter occurrence
Write a java program to count the number of occurrence of the each letter in the given string
Exercise 4: Count Words
Write a Java program to count the number of words in the given string
Exercise 5: Palindrome and anagram
Write a java program to check the given string is palindrome or not (Example: Race car)
Write a java program to check the given string is anagram or not (Example Iceman vs Cinema)
Exercise 6: Comparison of product version number
Write a java program that read a two string of the given format and compares the string
Example:
15.10.10 is greater than 14.20.50 as 15 >14
14.12.10 is greater than 14.10.55 as 12>10
14.10.15 is greter than 14.10.11 as 15>11
Hint:GivenString.split(\.)
Exercise 7: Email validity
Write a java program using String methods to compare the email is valid is invalid and returns the username and domain name
i) Valid Username: numbers[0-7], alphabets[a-z][A-Z], underscore, dot, hypen and plus characters
ii) Presence of @ symbol
iii) Presence of domainname.com or .in or .edu
Hint use givenstring.split(“@”) to find specific user(case-insensitive: jc_vp) and specific domain (case-insensitive: gmail.com) for example jc_vp@gmail.com.
Exercise 8: Dictionary
Write a java program to create a dictionary using 2D string array for any 10 programming languages. Write a method that return the definition for the input of PL name.
Java- pure object oriented programming language by James Gosling
C++ – Object oriented programming language by Stroustrup




Reviews
There are no reviews yet.