02 2013 档案
Java语言程序设计-基础篇-第八版-编程练习题-第九章
摘要:package 编程练习题chapter9;import java.util.Scanner;public class Exercise9_1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter a string for SSN: "); String s = input.nextLine(); if (isValidSSN(s)) { ...
阅读全文
Java语言程序设计-基础篇-第八版-编程练习题-第八章
摘要:package 编程练习题chapter8;import java.util.GregorianCalendar;public class Exercise8_5 { public static void main(String[] args) { GregorianCalendar calendar = new GregorianCalendar(); System.out.println("Year is " + calendar.get(GregorianCalendar.YEAR)); System.out.println("Month ...
阅读全文
Java语言程序设计-基础篇-第八版-编程练习题-第七章
摘要:package 编程练习题chapter7;import java.util.Scanner;public class Exercise7_1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a 4 by 4 matrix row by row: "); double[][] m = new double[4][4]; for (int i = 0; i < 4; i+...
阅读全文
Java语言程序设计-基础篇-第八版-第九章
摘要:package chapter9字符串和文本IO;import java.util.Scanner;public class PalindromeIgnoreNonAlphanumeric { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a string: "); String s = input.nextLine(); System.out.println("Igno...
阅读全文
Java语言程序设计-基础篇-第八版-第八章
摘要:1 package chapter8对象和类; 2 3 public class Circle2 { 4 double radius; 5 static int numberOfObjects = 0; 6 7 Circle2() { 8 radius = 1.0; 9 numberOfObjects++;10 }11 12 Circle2(double newRadius) {13 radius = newRadius;14 numberOfObjects++;15 }16 ...
阅读全文
Java语言程序设计-基础篇-第八版-复习题-第七章
摘要:Chapter 7 Multidimensional Arrays1 int[][] m = new int[4][5];2 二维数组可以有不同的长度。3 array[0][1] is 2.4.int[][] r = new int[2]; Answer: Invalidint[] x = new int[]; Answer: Invalidint[][] y = new int[3][]; Answer: Valid5. 因为我们需要排序list,排序list将改变list中的内容,唤起is1To9(grid[i])后grid数组中的内容也将改变。Grid中的内容将会改变,因此我们不能使用.
阅读全文
Java语言程序设计-基础篇-第八版-复习题-第九章
摘要:Chapter 9 Strings and Text I/O 1.s1 == s2 => trues2 == s3 => falses1.equals(s2) => trues2.equals(s3) => trues1.compareTo(s2) => 0s2.compareTo(s3) => 0s1 == s4 => trues1.charAt(0) => Ws1.indexOf('j') => -1s1.indexOf("to") => 8s1.lastIndexOf('a')
阅读全文
Java语言程序设计-基础篇-第八版-复习题-第八章
摘要:Chapter 8 Objects and Classes1. See the section "Declaring and Creating Objects."2. 构造方法是在创建一个对象使用new操作符时调用的。 构造方法没有返回类型,甚至连void也没有。数组是一个对象。 The default value for the elements of an array is 0 for numeric, false for boolean, ‘\u0000’ for char, null for object element type.(a) There is such
阅读全文
Java语言程序设计-基础篇-第八版-编程练习题-第六章
摘要:1 package 编程练习题chapter6; 2 import java.util.Scanner; 3 public class Exercise6_01Extra { 4 public static void main(String[] args){ 5 Scanner input = new Scanner(System.in); 6 boolean[] isCovered = new boolean[99]; 7 8 int number = input.nextInt(); 9 while...
阅读全文
Java语言程序设计-基础篇-第八版-编程练习题-第五章
摘要:1 package 编程练习题chapter5; 2 import java.util.*; //我改了; 3 public class Exercise5_1 { 4 public static void main (String args[]) { 5 Scanner input = new Scanner(System.in); 6 7 System.out.print("Enter a number: "); 8 int number = input.nextInt(); 9 10 ...
阅读全文
Java语言程序设计-基础篇-第八版-复习题-第六章
摘要:Chapter6Single-dimensionalArrays3声明数组时不分配内存。创建数组时分配内存。xis60Thesizeofnumbersis304.1. 数组中每个元素都有相同的类型。Answer:True2. 一旦数组被声明,大小不能改变。 Answer:False3. 一旦数组被创建,大小不能改变。Answer:True4. 数组中的元素必须是基本数据类型。Answer:False5. Whichofthefollowingstatementsarevalidarraydeclarations?inti=newint(30);Answer:Invaliddoubled[]=n
阅读全文
Java语言程序设计-基础篇-第八版-复习题-第五章
摘要:Chapter5Methods1.Atleastthreebenefits:(1)Reusecode;(2)Reducecomplexity;(3)Easytomaintain.SeetheSections5.2and5.3onhowtodeclareandinvokemethods.Whatisthesubtledifferencebetween“definingamethod”and“declaringavariable”?Adeclarationusuallyinvolvesallocatingmemorytostoreavariable,butadefinitiondoesn’t.2.
阅读全文
Java语言程序设计-基础篇-第八版-第七章
摘要:1 package chapter7; 2 3 public class PassTwoDimensionalArray { 4 public static void main (String[] args) { 5 java.util.Scanner input = new java.util.Scanner(System.in); 6 7 int[][] m = new int[3][4]; 8 System.out.println("Enter " + m.length + " rows and " + 9 ...
阅读全文
Java语言程序设计-基础篇-第八版-第六章
摘要:1 package chapter6一维数组; 2 3 public class Arrays类 { 4 public static void main(String[] args){ 5 6 double[] numbers = {6.0, 4.4, 1.9, 2.9, 3.4, 3.5}; 7 java.util.Arrays.sort(numbers); 8 9 int[] list = {2, 4, 7, 10};10 System.out.println(java.util...
阅读全文
浙公网安备 33010602011771号