Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
UNIVERSITY OF LONDON
GOLDSMITHS COLLEGE
B. Sc. Examination 2003
COMPUTER SCIENCE
IS51008A(CIS109) Introduction to Java and
Object–Oriented Programming
Duration: 3 hours
Date and time:
Answer all 10 questions from section A (multiple choice) and 6 questions from section B.
Each question from Section A is worth 2 marks (20 marks in total) and each question from
section B is worth 10 marks (60 marks in total).
THIS EXAMINATION PAPER MUST NOT BE REMOVED
FROM THE EXAMINATION ROOM
Section A(20 Marks)
Answer all questions from section A
QUESTION 1
Consider the following program:-
public class A
{
public static void main(String[] args)
{
System.out.println(x+1);
}
}
Which one of the following is true:
(a) This program has a compilation error.
(b) This program will compile correctly.
(c) None of the above.
IS51008A(CIS109) 2003 1 TURN OVER
QUESTION 2
Consider the following program:-
public class A
{
public static void main(String[] args)
{
int x=1;
int y=2;
x=y;
y=x;
System.out.println(y);
}
}
Which one of the following is true:
(a) This program has a compilation error
(b) This program prints 2
(c) This program prints 1
(d) None of the above.
IS51008A(CIS109) 2003 2 TURN OVER
QUESTION 3
Consider the following program:-
public class A
{
public static void main(String[] args)
{
System.out.println("a");
System.out.print("b");
System.out.print("c");
}
}
Which one of the following is true:
(a) This program prints
a
b
c
(b) This program prints
ab
c
(c) This program prints
a
bc
(d) None of the above.
IS51008A(CIS109) 2003 3 TURN OVER
QUESTION 4
Consider the following program:-
class div1
{
public static void main(String[] args)
{
System.out.println(3/2);//int divided by int
}
}
Which one of the following is true:
(a) This program prints 1
(b) This program prints 1.5
(c) This program prints 2
(d) None of the above.
IS51008A(CIS109) 2003 4 TURN OVER
QUESTION 5
Consider the following program:-
class W
{
public static void main(String[] args)
{
String s; //Declaration of variable s
s = 1; // assignment statement
System.out.println(s);
}
}
Which one of the following is true:
(a) This program has a compilation error
(b) This program prints 1
(c) None of the above.
IS51008A(CIS109) 2003 5 TURN OVER
QUESTION 6
What is the value of the following expression:- (1<2 && (2<1 || 3==4))
(a) true
(b) false
(c) None of the above.
IS51008A(CIS109) 2003 6 TURN OVER
QUESTION 7
Consider the following program:-
class W
{
public static void main(String[] args)
{
if (1<2) System.out.print(1);
else System.out.print(2); System.out.print(3);
}
}
Which one of the following is true:
(a) This program has a compilation error
(b) This program prints 13
(c) This program prints 23
(d) None of the above.
IS51008A(CIS109) 2003 7 TURN OVER
QUESTION 8
Consider the following program:-
public class C
{
public static void main(String[] args)
{
int i
for(i=1;i<5;i++);
System.out.println(i);
}
}
Which of the following best describes its behaviour.
(a) 4 will be printed
(b) 5 will be printed
(c) 6 will be printed
(d) None of the above.
IS51008A(CIS109) 2003 8 TURN OVER
QUESTION 9
Consider the method p.
static int p(int n)
{
return (n+1);
}
Which of the following is a legal call to p?
(a) p();
(b) p(3);
(c) p(3,2);
(d) p("hello");
IS51008A(CIS109) 2003 9 TURN OVER
QUESTION 10
Consider the program:
public class F
{
static void p(int n)
{for (int i=0;i