JAVA program to accomplish task using string/string Buffer class

By | June 11, 2017

Write a program to Implement a program to accomplish the following task using string/string Buffer class:
i. Accept a password from the user.
ii. Check if password is correct then display “Good”
Else display “Incorrect password”
iii. Append the password with the string “Welcome to Java!!!”
iv. Display the password in reverse order.
v. Replace the character ‘!’ in password with “*” character.

import java.lang.*;
class q6String
	public static void main(String args[]) throws IOException
		BufferedReader br = new BufferedReader(new InputStreamReader(;
		String s1 = "!!sspp!!";
		String s2;
		System.out.println ("Enter Password");
		s2 = br.readLine();
			System.out.println ("Good");
			System.out.println ("Password is incorrect");
		String s3 = "Welcome to Java!!!";
		StringBuffer sb = new StringBuffer(s1);
		System.out.println ("Appended Password = "+sb);
		StringBuffer s4 = new StringBuffer(s1);
		System.out.println ("String in Reverse Order = "+s4);
		System.out.println ("Replaced '!' with '*' = "+s1.replace('!','*'));	


Author: rabins

Rabins is CEO of R.S. Softwares Private Limited, a software and IT company in Nepal. He runs Nepal's first Internet of Things (IoT) website. He is the owner of RabinsXP who is constantly working for increasing IoT in Nepal. He also builds Android, iOS and Web Apps and crafts beautiful websites. He is also working with various social services. The main aim of Lamichhane is to digitally empower the citizens of Nepal and make the world spiritually sound better both in terms of technology and personal development. RabinsXP is the internet nickname of Rabins Sharma Lamichhane too.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.