字符串
1.什么是字符串常量?
答:字符串字面常量是一串以双引号作为字符串的定界符。
2.print和println方法有什么不同?
答:print方法不可以换行;而println可以换行。
3.什么是参数?
答:参数是当调用方法时传递给方法的数据。
4.下面代码段产生的输出是什么?
System.out.println("One"); One
System.out.print("Two"); Two Three
System.out.println("Three");
System.out.print("Ready"); Ready
System.out.println(); Set
System.out.println("Set");
System.out.println(); Go
System.out.println("Go");
6.下列语句产生的输出是什么?如果去掉内层括号,输出又会是什么?
System.out.println("It is good to be"+(5+5));
输出时是 It is good to be10
去括号时是 It is good to be 55
7.什么是转义序列?给出几个例子。yi
答:转义序列是以反斜线(\)开头的一系列字符,反斜线说明其后面的字符要以特殊的形式对待。例如,\n表示字符换行,\t表示制表符,\"表示字符双引号(而不是表示字符串的开始或结束)。
8.只编写一条Println语句,输出以下信息(包括换行和引号)。
"I made this letter longer than usual because I lack the time to make it short."
Blaise Pascal
答:System.out.println("\"I made this letter longer than"+"usual because I lakc the time to\nmake it short.\""+"\n\tBlaise Pascal");

浙公网安备 33010602011771号