Mock Exam
for Java 2 Programmer
This is a set of questions for those who are preparing
for the java 2 programmer exam (SCJP)
Q1-The following program is in file Test.java, what would
be the output
class MyFirstClass{
public class Test{
public class MyThirdClass{
a) compiles, runs and does not print anything
Q2-The following program is in file Test.java, what would be the output of compiling and running this program ?
public class Test implements Runnable{
public void run(){
a) does not compile
Q3-The following program is in file Test.java, what would be the output of compiling and running this program ?
public class Test {
a) compiles, runs and prints " 10s66 "
Q4-The following program is in file Test.java, what would be the output of compiling and running this program ?
public class Test {
a) compiles, runs and prints " yes "
Q5-The following program is in file Test.java, what would be the output of compiling and running this program ?
public class Test {
public void printMessage(float f){
public static void main(String str[]){
a) compiles, runs and prints " object number 10 created
"
Q6-The following program is in file Test.java, what would be the output of compiling and running this program ?
public class Test {
} a) compiles, runs and prints
Q7-The following program is in file Test.java, what would be the output of compiling and running this program ?
public class Test {
} a) compiles, runs and prints "0"
Q8-The following program is in file Test.java, what would be the output of compiling and running this program ?
class MyFirstClass{
public class Test extends MyFirstClass {
public Test(){
public static void main(String st[]){
a) compiles, runs and prints ", we are in Test we are
in MyFirstClass"
Q9-The following program is compiled and run, what is printed on the Frame when button b2 is clicked? import java.awt.event.*; public class Test extends Frame implements ActionListener{
private Button b1;
public Test(){
public void actionPerformed(ActionEvent ae){
public void paint(Graphics g){
public static void main(String st[]){
a) "message"
Q10-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
public static void main(String st[]){
a) compiles, runs and prints "true false"
Q11-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
public static void main(String st[]){
a) compiles, runs and prints "1 1 2 2"
Q12-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
public static void main(String st[]){
a) does not compile
Q13-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
public static void main(String st[]){
a) does not compile
Q14-Which of the following codes is(are) ILLEGAL ? a)
interface Int1{
b)
interface Int1{
c)
interface Int1{
Q15-Which of the following codes do(es) not compile ? a)
class MyFirstClass {
abstract class MySecondClass {
b)
class MyFirstClass {
abstract class MySecondClass {
c)
class MyFirstClass {
abstract class MySecondClass {
d)
class MyFirstClass {
abstract class MySecondClass {
|
Q16-The following program is in file Test.java, what would
be the output
public class Test {
public void method1(int
a, int b){
System.out.println("after finally"); }
a) compiles, runs and prints
b) compiles, runs and prints
Q17-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
public void method1(int
a, int b){
a) compiles, runs and prints
b) compiles, runs and prints
Q18-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test { public static void main(String
st[]){
public void method2(){
a) does not compile.
Q19-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test { public static void main(String
st[]){
public void method2(){
a) compiles, runs and prints "output is =100.0"
Q20-Which of the statements a) b) c) d) would compile if inserted at line 5 import java.io.*; 1: public class Test {
a) InputStream iout = new InputStream(f1);
Q21-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) compiles, runs and prints "99"
Q22-Which of the statements a) b) c) d) would compile and run if inserted at line 4. 1: public class Test {
a) System.out.println(s[0][1]);
Q23-Which of the statements would NOT compile ? a) int x = (int)56L;
Q24-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) does not compile.
Q25-Which of the statements a) b) c) d) would NOT compile if inserted at line 6 1: class MyFirstClass {
a) System.out.println(y);
Q26-The following program is in file Test.java, what would be the output of compiling and running this program ? class MyFirstClass{
public void
show(){
public class Test extends MyFirstClass{
a) compiles, runs and prints
Q27-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) compiles, runs and prints
Q28-When you invoke repaint() for a component, which method is called? a) paint
Q29- Which of these names for variables are ILLEGAL ? a) +var
Q30-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) compiles, runs and prints "true true true"
Q31-The following program is in file Test.java, what would be the output of compiling and running this program ? import java.awt.*; public class Test extends Frame{
a) compiles, runs and a frame shows up with "Maria" printed
Q32-The following program is in file Test.java, what would be the output of compiling and running this program ? class PrintMess{
a) compiles, runs and prints "aaaaabbbbb"
Q33-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) compiles, runs and prints "default case 4 "
Q34-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
int x = 0;
a) compiles, runs and prints "while while"
Q35-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
for(int i=0; i<=1 ; i++)
}
a) compiles, runs and prints "00011011"
Q36-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) compiles, runs and prints "x equals y"
Q37-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) compiles, runs and prints "7.6 49"
Q38-The following program is in file Test.java, what would be the output of compiling and running this program ? public class Test {
a) does not compile
Answers Answer to Q1: b) Answer to Q2: d) Answer to Q3: a) Answer to Q4: c) Answer to Q5: d) Answer to Q6: a) Answer to Q7: b) Answer to Q8: d) Answer to Q9: c) Answer to Q10: a) Answer to Q11: d) Answer to Q12: c) Answer to Q13: a) Answer to Q14: b) c) d) Answer to Q15: a) b) Answer to Q16: c) Answer to Q17: d) Answer to Q18: b) Answer to Q19: a) Answer to Q20: b) c) d) Answer to Q21: c) Answer to Q22: a) c) Answer to Q23: b) d) Answer to Q24: c) Answer to Q25: a) c) Answer to Q26: d) Answer to Q27: a) Answer to Q28: b) Answer to Q29: a) b) Answer to Q30: d) Answer to Q31: b) Answer to Q32: b) Answer to Q33: c) Answer to Q34: a) Answer to Q35: d) Answer to Q36: b) Answer to Q37: a) Answer to Q38: a)
Related:
Java Certification, Programming, JavaBean and Object Oriented Reference Books Return to : Java Programming Hints and Tips All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|