tringBuffer str1=new StringBuffer(“Mary was a”); РStringBuffer str2=str1.replace(5,10,”had a book.”);Р System.out.println(str2); Р}Р }Р解题方案:Р评分标准:Р结构3分,功能实现4分,语法3分Р3. Р参考答案:Р解题方案:Р评分标准:Р结构3分,功能实现4分,语法3分Р4. Р参考答案:Рimport java.io.*;Р public class Prime Р{Р public static void main(String[] args) Р{Р String s = "";Р int n = 0; РSystem.out.print("请输入一个整数:"); Рtry{ InputStreamReader isr = new InputStreamReader(System.in);Р BufferedReader br = new BufferedReader(isr); Рs = br.readLine();Р n = Integer.parseInt(s); Р}Рcatch(IOException e)Р { Р}Р if( isPrime(n) ) System.out.println(n + "是素数."); Рelse System.out.println(n + "不是素数."); Р}Р static boolean isPrime(int a)Р {Р if(a == 1) return false;Р if(a == 2) return true;Р for(int i = 2; i <= a/2; i++) if( a % i == 0 ) return false; Рreturn true;Р }Р }