AP

网络课堂

新东方在线 > ap > 动态 > 正文

新东方在线独家:2015年AP计算机预测题

2015-04-01 17:18:16 来源:网络新东方AP课程
分享到:
摘要:本文为新东方在线AP名师杜明磊老师写的2015年AP计算机预测题,供大家备考2015年AP考试时使用。

  本文为新东方在线AP名师杜明磊老师写的2015年AP计算机预测题,供大家备考2015年AP考试时使用。

\新东方在线热报AP课程~

  1.

  How can we produces a random between 3and55?

  Answer:(int) (Math.random()*53+3)

  2.

  int a = 5;

  int b = 2;

  if ((a < 3) && (b > 1))

  System.out.println("Value is: " + a * a);

  else

  System.out.println("Value is: " + b / a);

  What is the result of executing the code segment?

  Answer: 0

  Consider the Student Class for question 3 and 4.

  public class Student

  {

  //data members

  private String myName;

  private String myGrade;

  //constructors

  public Student()

  {

  myName = "";

  myGrade = "";

  }

  //constructors

  public Student(String name, String grade)

  {

  myName = name;

  myGrade = grade;

  }

  public String getName()

  { returnmyName; }

  public String getGrade()

  { returnmyGrade; }

  public void chaName(String a)

  { myName = a; }

  public void setGrade(String newGrade)

  { myGrade = newGrade; }

  //

  }

  3. Student stu=new Student(Jame,Good);

  Write the code to change the name of stufrom "Jame" to "Tom" ?

  Answer:stu.chaName(“Tom”);

  4. Which of the following declarations will compile without error?

  I. Student a = new Student();

  II. Student b = new Student("Tome", “Good”);

  III. Student c = new Student("Matt", 120);

  Answer: I andII

  5.

  public String MethodA(String in)

  {

  String out = "";

  for (int i = 1; i< + i="i">

  {

  out += in.substring(i, i + 1);

  }

  return out;

  }

  What is returned as a result of the call MethodA("mytoycat") ?

  Answer: “yyt”

  6.

  public static intSum(int[] arr)

  {

  int sum = 0;

  for (int i = 1; i <= arr.length; i++)

  {

  /* some code */

  }

  return sum;

  }

  If we want the sum give us the some of the Array arr, what can be the/* some code */

  Answer: sum+=arr[i-1]

  7.

  public static intmethodA(int[] arr)

  {

  int x = 0;

  for (int k = 0; k < + k="k">

  x = x + arr[k];

  return x;

  }

  If the array num has been declared and initialized as follows.

  int[] num = {1,2,3,4,5,6,7,8,9,10};

  What value will be returned as a result of the call methodA(num)?

  Answer:22

  8.

  publicArrayListmethodB(int n)

  {

  ArrayList sec = new ArrayList();

  for (int k = 0; k < n; k++)

  seq.add(new Integer(k * 2 + 2));

  return sec;

  }

  What the result of executing the following statement?

  System.out.println(methodB(7));

  Answer: [2,4,6,8,10,12,14]

  9.

  int[] ArrayA = {1,2,3,4,5,6,7,8,9,10,11,12};

  int[][] ArrayB = new int[3][4];

  int row = 0;

  int col = 0;

  for (int value : ArrayA)

  {

  ArrayB[row][col] = value;

  col++;

  if ((col % 4) == 0)

  {

  row++;

  row = 0;

  }

  }

  What will be the ArrayB? Fill the table below to demonstrate that:

  Answer:

1

2

3

4

5

6

7

8

9

10

11

12

本文为新东方在线|AP频道独家文章,禁止转载!

  作者介绍:杜明磊

  

  *河北师范大学数学教育硕士,高级家庭教育指导师。

  北京昌平新东方外国语学校优秀教师。* 新东方教育集团年度优秀员工。

  *美国大学理事会AP微积分、AP计算机科学A 授权认证教师.

  *教学特色:

  *10年基础教育经验,能深刻理解学生在学习过程中的心理感受。

  * 善于把知识“翻译”成学生容易理解的形式,让学生紧紧抓住进步的阶梯。能够深刻洞察学生在学习成长过程中的动向,适时引导。

责任编辑:lisihan

编辑推荐

AP网络课堂更多>>

AP公开课更多>>

AP热报课程本月本周

专题推荐

聚合阅读