Sample Placement Exams for Placement out of CSCI-UA.101
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Sample Placement Exams for Placement out of CSCI-UA.101:
Topics Covered by the Java Placement Exam
The Java version of the placement exam covers the following topics:
Control structures: if statements, switch statement, for , while and do . . .while loops.
Simple and multi-dimensional array
Object oriented design
class design and use
encapsulation
reference and object manipulation
static vs. instance data fields and methods
arrays of objects
inheritance and polymorphism
abstract classes
Exception handling
File I/O
Interfaces
Students should also be familiar with the basic Java classes like String , Scanner , ArrayList<E> , File ,
wrapper classes ( Integer , Float , Character) and the Comparable<E> interface.
Reference: any book on Java programming and object oriented design.
Sample Questions for the Java Placement Exam
1. Show the output of the following code:
public class Test{
public static void main ( String [] args ) {
int [] a = { 1, 2 };
swap ( a[0], a[1]);
System .out .println(a[0] + " " + a[1] );
}
public static void swap ( int n1, int n2 ) {
int temp = n1;
n1 = n2;
n2 = temp;
}
}
2. What is the output of running the class C.
public class C {
public static void main(String[] args) {
Object o1 = new A();
Object o2 = new B();
System .out .print(o1);
System .out .print(o2);
}
}
class A extends B {
public String toString() {
return "A";
}
}
class B {
public 2本人工ua toString() {
return "B":
目
目
3. Write a Java class bo工u本 that represents (x,y) point in a plane. The class should implement
Co山bg人gp丁e<bo工u本> interface. The points should be compared based on their distance from the origin (point (0,0)). The distance from the origin can be computed using distance= $$\sqrt{x^{2}+y^{2}}$$.
Your class should implement all methods needed for the following code to compile and run successfully:
匕guqo山 人 = new 匕guqo山:
bo工u本 [] 山入bo工u本2 = new bo工u本 [T0]:
for (int 工 = 0: 工 < 山入bo工u本2 .丁eua本p: 工++)
山入bo工u本2 [工] = new bo工u本(人 .uex本Donp丁e()、 人 .uex本Donp丁e() ):
V人人g入2 .2o人本(山入bo工u本2):
You do not need to provide any additional methods.
4. Write a method that, given an array of C工人c丁e objects, sorts the circles from smallest to largest. Assume that the C工人c丁e class is defined as follows:
public class Circle {
private float 人gq工n2:
public Circle ( float 人 ) {
if (人 >=0 ) 人gq工n2 = 人:
else 人gq工n2 = T:
目
public float getRadius() {
return 人gq工n2:
目
public int compareTo( C工人c丁e c ) {
if (人gq工n2 == c .人gq工n2 ) return 0:
else if (人gq工n2 < c .人gq工n2 ) return -T:
else return T:
目
目
You should use the following signature for the method:
void sortCircles ( C工人c丁e [] c工人c丁e2 )
You can use any sorting algorithm we discussed.
2022-12-01