Java Strings Part 3

 

public class Strings {
	public static void main(String ads[]){
		String a="meow";
		String ab="meow"+"deal";
		String abc="meowdeal";
		System.out.println(ab==abc);
	}
}

 

How many objects are created ?  

public class Strings {
public static void main(String ads[]){
String abc="abc";
String upperTest="ABC";
String upper=abc.toUpperCase();
}
}

 

What happens when you compile and run the program below

 

public class Strings {
	public static void main(String ads[]){
		String abc="abc";
		StringBuffer sb="abc";
		System.out.println(abc.equals(sb));
	}
}

 

What will be the output of the following code ? 

 

public class Strings {
			public static void main(String ads[]){
				String file="myfile";
				FileTest f= new FileTest(file);
				String fileName=f.getName();
				System.out.println(file==fileName);
			}
		
}
		class FileTest{
			private String name;
			FileTest(String name){
				this.name=name;
			}
			public String getName(){
				String temp=this.name;
				return temp;
			}
		}