尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
1
JAVA TEST
Time allowed: 30 minutes
NAME:
EMAIL:
DATE:
2
Question# 1
Which of the following are keywords or reserved words in Java?
A. if B. then
C. goto D. while
E. case
Question# 2
A byte can be of what size
A. -128 to 127
B. (-2 power 8)-1 to 2 power 8
C. -255 to 256
D. depends on the particular implementation of the Java Virtual machine
Question# 3
What will happen if you try to compile and run the following code?
public class Q {
public static void main(String argv[]){
int anar[]=new int[]{1, 2, 3};
System.out.println(anar[1]);
}
}
A. 1 B. Error anar is referenced before it is initialized
C. 2 D. Error: size of array must be defined
Question# 4
Given the following declarations
String s1=new String("Hello");
String s2=new String("there");
String s3=new String();
Which of the following are legal operations?
A. s3=s1 + s2; B. s3=s1 - s2;
C. s3=s1 & s2; D. s3=s1 && s2
3
Question# 5
What will happen when you compile and run the following code?
public class MyClass{
static int i;
public static void main(String argv[]){
System.out.println(i);
}
}
A. Error Variable i may not have been initialized
B. null
C. 1
D. 0
Question# 6
Which of the following statements are true?
A. Methods cannot be overriden to be more private
B. Static methods cannot be overloaded
C. Private methods cannot be overloaded
D. An overloaded method cannot throw exceptions not checked in the base class
Question# 7
What will be the result of attempting to compile and run the following code?
abstract class MineBase {
abstract void amethod();
static int i;
}
public class Mine extends MineBase {
public static void main(String argv[]){
int[] ar=new int[5];
for(i=0;i < ar.length;i++)
}
}
A. a sequence of 5 0's will be printed
B. Error: ar is used before it is initialized
C. Error Mine must be declared abstract
D. IndexOutOfBoundes Error
4
Question# 8
What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current
directory?
import java.io.*;
public class Mine {
public static void main(String argv[]){
Mine m=new Mine();
System.out.println(m.amethod());
}
public int amethod() {
try {
FileInputStream dis=new FileInputStream("Hello.txt");
}catch (FileNotFoundException fne) {
System.out.println("No such file found");
return -1;
}catch(IOException ioe) {
} finally{
System.out.println("Doing finally");
}
return 0;
}
}
A. No such file found
B. No such file found, -1
C. No such file found, Doing finally, -1
D. 0
Question# 9
Which of the following statements are true?
A. System.out.println(-1>>>2); will output a result larger than 10
B. System.out.println(-1>>>2); will output a positive number
C. System.out.println(2>>1); will output the number 1
D. System.out.println(1<<<2); will output the number 4
5
Question# 10
What will be displayed when you attempt to compile and run the following code
//Code start
import java.awt.*;
public class Butt extends Frame{
public static void main(String argv[]){
Butt MyBut=new Butt();
}
Butt(){
Button HelloBut=new Button("Hello");
Button ByeBut=new Button("Bye");
add(HelloBut);
add(ByeBut);
setSize(300,300);
setVisible(true);
}
}
//Code end
A. Two buttons side by side occupying all of the frame, Hello on the left and Bye on the right
B. One button occupying the entire frame saying Hello
C. One button occupying the entire frame saying Bye
D. Two buttons at the top of the frame one saying Hello the other saying Bye
Question# 12 - 11
If g is a graphics instance what will the following code draw on the screen?
g.fillArc(45,90,50,50,90,180);
A. An arc bounded by a box of height 45, width 90 with a centre point of 50, 50, starting at an angle of 90 degrees
traversing through 180 degrees counter clockwise.
B. An arc bounded by a box of height 50, width 50, with a centre point of 45, 90, starting at an angle of 90 degrees
traversing through 180 degrees clockwise.
C. An arc bounded by a box of height 50, width 50 with a top left at coordinates of 45, 90, starting at 90 degrees and
traversing through 180 degrees counter clockwise.
D. An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a box of height 50, width 50
with a centre point of 90, 180.
6
Question# 11 - 12
If you wanted to find out where the position of the letter v (ie return 2) in the string s containing "Java", which of the
following could you use?
A. mid(2,s); B. charAt(2);
C. s.indexOf('v'); D. indexOf(s,'v');
Question# 13
What code placed after the comment //For loop would populate the elements of the array ia[] with values of the variable i.?
public class Lin{
public static void main(String argv[]){
Lin l = new Lin();
l.amethod();
}
public void amethod(){
int ia[] = new int[4];
//Start For loop
{
ia[i]=i;
System.out.println(ia[i]);
}
}
}
A. for(int i=0; i < ia.length() -1; i++)
B. for(int i=0; i < ia.length(); i++)
C. for(int i=1; i < 4; i++)
D. for(int i=0; i< ia.length;i++)
Question# 15 - 14
An Applet has its Layout Manager set to the default of FlowLayout. What code would be correct to change to another
Layout manager?
A. set LayoutManager(new GridLayout());
B. set Layout(new GridLayout(2,2));
C. setGridLayout(2,2);
D. setBorderLayout();
7
Question# 14 - 15
Which of the following will output -4.0
A. System.out.println(Math.floor(-4.7)); B. System.out.println(Math.round(-4.7));
C. System.out.println(Math.ceil(-4.7)); D. System.out.println(Math.min(-4.7));
Question# 16
What will be the result when you attempt to compile and run the following code?
public class Conv{
public static void main(String argv[]){
Conv c=new Conv();
String s=new String("ello");
c.amethod(s);
}
public void amethod(String s){
char c='H';
c+=s;
System.out.println(c);
}
}
A. Compilation and output the string "Hello"
B. Compilation and output the String "ello"
C. Compilation and output the string elloH
D. Compile time error
Question# 23 - 17
What will the following code print out?
public class Oct{
public static void main(String argv[]){
Oct o = new Oct();
o.amethod();
}
public void amethod(){
int oi= 012;
System.out.println(oi);
}
}
A. 12 B. 012
C. 10 D. 10.0
Question# 17 - 18
8
What will be printed out if this code is run with the following command line?
java Myprog good morning
public class Myprog{
public static void main(String argv[]){
System.out.println(argv[2])
}
}
A. myprog
B. good
C. morning
D. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"
Question# 18 - 19
If you create a TextField with a constructor to set it to occupy 5 columns, what difference will it make if you use it with a
proportional font (ie Times Roman) or a fixed pitch typewriter style font (Courier)
A. With a fixed font you will see 5 characters,with a proportional it will depend on the width of the characters
B. With a fixed font you will see 5 characters,with a proportional it will cause the field to expand to fit the text
C. The columns setting does not affect the number of characters displayed
D. Both will show exactly 5 characters
Question# 19 - 20
Given the following code:
import java.awt.*;
public class SetF extends Frame{
public static void main(String argv[]){
SetF s=new SetF();
s.setSize(300,200);
s.setVisible(true);
}
}
How could you set the frame su
A. s.setBackground(Color.pink);
B. s.setColor(PINK);
C. s.Background(pink);
D. s.color=Color.pink
Question# 20 - 21
Given the following code what will be output?
9
public class Pass{
static int j=20;
public static void main(String argv[]){
int i=10;
Pass p = new Pass();
p.amethod(i);
System.out.println(i);
System.out.println(j);
}
public void amethod(int x){
x=x*2;
j=j*2;
}
}
A. Error: amethod parameter does not match variable
B. 20 and 40
C. 10 and 40
D. 10, and 20
Question# 21 - 22
Which of the following can you perform using the File class?
A. Change the current directory
B. Return the name of the parent directory
C. Delete a file
D. Find if a file contains text or binary information
Question# 24 - 23
What is the result of the following operation?
System.out.println(4 | 3);
A. 6 B. 0
C. 1 D. 7
10
Question# 22 - 24
What will be the result when you try to compile and run the following code?
private class Base{
Base(){
int i = 100;
System.out.println(i);
}
}
public class Pri extends Base{
static int i = 200;
public static void main(String argv[]){
Pri p = new Pri();
System.out.println(i);
}
}
A. Error at compile time B. 200
C. 100 followed by 200 D. 100
Question# 25
What will happen when you try compiling and running this code?
public class Ref{
public static void main(String argv[]){
Ref r = new Ref();
r.amethod(r);
}
public void amethod(Ref r){
int i=99;
multi(r);
System.out.println(i);
}
public void mult(Ref r){
r.i = r.i*2;
}
}
A. Error at compile time B. An output of 99
C. An output of 198 D. An error at runtime
Question# 27 - 26
11
Which of the following will compile without error?
A.
import java.awt.*;
package Mypackage;
class Myclass{}
B.
package MyPackage;
import java.awt.*;
class MyClass{}
C.
package MyPackage;
importjava.awt.*;
class MyClass{}
Question# 28 - 27
Which of the following will successfully crate an instance of the Vector class and add an element?
A.
Vector v=new Vector(99);
v[1]=99;
C.
Vector v=new Vector();
v.add(99);
B.
Vector v=new Vetor();
v.addElement(99);
D.
Vector v=new Vector(100);
v.addElement("99");
Question# 29 - 28
What will happen when you compile and run the following code?
public class Scope{
private int i;
public static void main(String argv[])}
Scope s = new Scope();
s.amethod();
}//End of main
public static void amethod(){
System.out.println(i);
}//end of amethod
}//End of class
A. A value of 0 will be printed out
B. Nothing will be printed out
C. A compile time error
D. A compile time error complaining of the csope of the variable i
Question# 26 - 29
What will be the result when you attempt to compile this program?
12
public class Rand{
public static void main(String argv[]){
int iRand;
iRand = Math.random();
System.out.println(iRand);
}
}
A. Compile time error referring to a cast problem
B. A random number between 1 and 10
C. A random number between 0 and 1
D. A compile time error about random being an unrecognised method
Question# 30
What will happen when you attempt to compile and run the following code
class Base{
private void amethod(int iBase){
System.out.println("Base.amethod");
}
}
class Over extends Base{
public static void main(String argv[]){
Over o = new Over();
int iBase=0;
o.amethod(iBase);
}
public void amethod(int iOver){
System.out.println("Over.amethod");
}
}
A. Runtime error complaining that Base.amethod is private
B. Output of "Base.amethod"
C. Output of "Over.amethod"
D. Compile time error complaining that Base.amethod is private
~ The end ~

More Related Content

What's hot

KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngDavid Nguyen
 
Đề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOT
Đề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOTĐề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOT
Đề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOT
Dịch vụ viết bài trọn gói ZALO 0917193864
 
Hệ mật mã Elgamal
Hệ mật mã ElgamalHệ mật mã Elgamal
Hệ mật mã Elgamal
Thành phố Đà Lạt
 
Kiến trúc máy tính và hợp ngữ bài 05
Kiến trúc máy tính và hợp ngữ bài 05Kiến trúc máy tính và hợp ngữ bài 05
Kiến trúc máy tính và hợp ngữ bài 05
Nhóc Nhóc
 
Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3Minh Ngoc Tran
 
Đề Cương ôn tập kiến trúc máy tính và thiết bị ngoại vi
Đề Cương ôn tập kiến trúc máy tính và thiết bị ngoại viĐề Cương ôn tập kiến trúc máy tính và thiết bị ngoại vi
Đề Cương ôn tập kiến trúc máy tính và thiết bị ngoại viĐỗ Đức Hùng
 
Bài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tínhBài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tínhCao Toa
 
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPTBài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
MasterCode.vn
 
Modern stream cipher
Modern stream cipherModern stream cipher
Modern stream cipher
Hoang Nguyen
 
Hệ mật mã elgamal
Hệ mật mã elgamalHệ mật mã elgamal
Hệ mật mã elgamal
Thành phố Đà Lạt
 
Sinh viên công nghệ thông tin và tương lai
Sinh viên công nghệ thông tin và tương laiSinh viên công nghệ thông tin và tương lai
Sinh viên công nghệ thông tin và tương lai
Thao Ho
 
Quy hoạch động
Quy hoạch độngQuy hoạch động
Quy hoạch độnghana_dt
 
Mã hóa đường cong Elliptic
Mã hóa đường cong EllipticMã hóa đường cong Elliptic
Mã hóa đường cong Elliptic
LE Ngoc Luyen
 
Đồ án kiểm thử phần mềm
Đồ án kiểm thử phần mềmĐồ án kiểm thử phần mềm
Đồ án kiểm thử phần mềm
Nguyễn Anh
 
Đề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOT
Đề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOTĐề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOT
Đề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOT
Dịch vụ viết bài trọn gói ZALO: 0909232620
 
Giáo trình lập trình GDI+
Giáo trình lập trình GDI+Giáo trình lập trình GDI+
Giáo trình lập trình GDI+
Sự Phạm Thành
 
Bài tập lớn Phát triển phần mềm hướng dịch vụ PTIT
Bài tập lớn Phát triển phần mềm hướng dịch vụ PTITBài tập lớn Phát triển phần mềm hướng dịch vụ PTIT
Bài tập lớn Phát triển phần mềm hướng dịch vụ PTIT
Popping Khiem - Funky Dance Crew PTIT
 
Hướng dẫn sử dụng phần mềm packet tracer
Hướng dẫn sử dụng phần mềm packet tracerHướng dẫn sử dụng phần mềm packet tracer
Hướng dẫn sử dụng phần mềm packet tracer
Bình Tân Phú
 
Phụ thuộc hàm và các dạng chuẩn - dhcntt
Phụ thuộc hàm và các dạng chuẩn - dhcnttPhụ thuộc hàm và các dạng chuẩn - dhcntt
Phụ thuộc hàm và các dạng chuẩn - dhcntt
anhhuycan83
 

What's hot (20)

KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm Động
 
Đề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOT
Đề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOTĐề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOT
Đề tài: Tìm hiểu mạng riêng ảo và ứng dụng, HOT
 
Hệ mật mã Elgamal
Hệ mật mã ElgamalHệ mật mã Elgamal
Hệ mật mã Elgamal
 
Kiến trúc máy tính và hợp ngữ bài 05
Kiến trúc máy tính và hợp ngữ bài 05Kiến trúc máy tính và hợp ngữ bài 05
Kiến trúc máy tính và hợp ngữ bài 05
 
Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3Lap trinh c++ có lời giải 3
Lap trinh c++ có lời giải 3
 
Đề Cương ôn tập kiến trúc máy tính và thiết bị ngoại vi
Đề Cương ôn tập kiến trúc máy tính và thiết bị ngoại viĐề Cương ôn tập kiến trúc máy tính và thiết bị ngoại vi
Đề Cương ôn tập kiến trúc máy tính và thiết bị ngoại vi
 
Bài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tínhBài giảng kiến trúc máy tính
Bài giảng kiến trúc máy tính
 
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPTBài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
 
Modern stream cipher
Modern stream cipherModern stream cipher
Modern stream cipher
 
Hệ mật mã elgamal
Hệ mật mã elgamalHệ mật mã elgamal
Hệ mật mã elgamal
 
Sinh viên công nghệ thông tin và tương lai
Sinh viên công nghệ thông tin và tương laiSinh viên công nghệ thông tin và tương lai
Sinh viên công nghệ thông tin và tương lai
 
Quy hoạch động
Quy hoạch độngQuy hoạch động
Quy hoạch động
 
Mã hóa đường cong Elliptic
Mã hóa đường cong EllipticMã hóa đường cong Elliptic
Mã hóa đường cong Elliptic
 
Đồ án kiểm thử phần mềm
Đồ án kiểm thử phần mềmĐồ án kiểm thử phần mềm
Đồ án kiểm thử phần mềm
 
Đề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOT
Đề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOTĐề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOT
Đề tài: Thuật toán quy hoạch động cho tính khoảng cách, HOT
 
Giáo trình lập trình GDI+
Giáo trình lập trình GDI+Giáo trình lập trình GDI+
Giáo trình lập trình GDI+
 
Bài tập lớn Phát triển phần mềm hướng dịch vụ PTIT
Bài tập lớn Phát triển phần mềm hướng dịch vụ PTITBài tập lớn Phát triển phần mềm hướng dịch vụ PTIT
Bài tập lớn Phát triển phần mềm hướng dịch vụ PTIT
 
MATMA - Chuong2
MATMA - Chuong2MATMA - Chuong2
MATMA - Chuong2
 
Hướng dẫn sử dụng phần mềm packet tracer
Hướng dẫn sử dụng phần mềm packet tracerHướng dẫn sử dụng phần mềm packet tracer
Hướng dẫn sử dụng phần mềm packet tracer
 
Phụ thuộc hàm và các dạng chuẩn - dhcntt
Phụ thuộc hàm và các dạng chuẩn - dhcnttPhụ thuộc hàm và các dạng chuẩn - dhcntt
Phụ thuộc hàm và các dạng chuẩn - dhcntt
 

Similar to FSOFT - Test Java Exam

1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional
Isabella789
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
Abhishekkumarsingh630054
 
Cbse marking scheme 2006 2011
Cbse marking scheme 2006  2011Cbse marking scheme 2006  2011
Cbse marking scheme 2006 2011
Praveen M Jigajinni
 
Core java
Core javaCore java
Core java
prabhatjon
 
7
77
C test
C testC test
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
Sujata Regoti
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
Vedant Gavhane
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
fntsofttech
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
Rumman Ansari
 
Java Generics
Java GenericsJava Generics
Java Generics
Carol McDonald
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
Miguel Vilaca
 
Scjp6.0
Scjp6.0Scjp6.0
Scjp6.0
prabhatkgupta
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii
Isabella789
 
Computer science ms
Computer science msComputer science ms
Computer science ms
B Bhuvanesh
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
ahmed8651
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Carol McDonald
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
IIUM
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
praveensomesh
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
MaruMengesha
 

Similar to FSOFT - Test Java Exam (20)

1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Cbse marking scheme 2006 2011
Cbse marking scheme 2006  2011Cbse marking scheme 2006  2011
Cbse marking scheme 2006 2011
 
Core java
Core javaCore java
Core java
 
7
77
7
 
C test
C testC test
C test
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
 
Scjp6.0
Scjp6.0Scjp6.0
Scjp6.0
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii
 
Computer science ms
Computer science msComputer science ms
Computer science ms
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
 

Recently uploaded

Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
Anand Bagmar
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
Zycus
 
Female Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service Available
Female Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service AvailableFemale Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service Available
Female Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service Available
isha sharman06
 
Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...
Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...
Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...
anshsharma8761
 
Photo Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdfPhoto Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdf
SERVE WELL CRM NASHIK
 
Digital Marketing Introduction and Conclusion
Digital Marketing Introduction and ConclusionDigital Marketing Introduction and Conclusion
Digital Marketing Introduction and Conclusion
Staff AgentAI
 
Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)
wonyong hwang
 
119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt
lavesingh522
 
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
sapnasaifi408
 
Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...
Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...
Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...
sapnasaifi408
 
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
 
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service AvailableCall Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
sapnaanpad7
 
What’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 UpdateWhat’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 Update
VictoriaMetrics
 
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx PolandExtreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Alberto Brandolini
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
confluent
 
Accelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAIAccelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAI
Ahmed Okour
 
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptxSAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
aneeshmanikantan2341
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
VictoriaMetrics
 
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
simmi singh$A17
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Vince Scalabrino
 

Recently uploaded (20)

Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
 
Female Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service Available
Female Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service AvailableFemale Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service Available
Female Bangalore Call Girls 👉 7023059433 👈 Vip Escorts Service Available
 
Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...
Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...
Call Girls Solapur ☎️ +91-7426014248 😍 Solapur Call Girl Beauty Girls Solapur...
 
Photo Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdfPhoto Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdf
 
Digital Marketing Introduction and Conclusion
Digital Marketing Introduction and ConclusionDigital Marketing Introduction and Conclusion
Digital Marketing Introduction and Conclusion
 
Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)
 
119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt
 
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
 
Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...
Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...
Independent Call Girls In Bangalore 💯Call Us 🔝 7426014248 🔝Independent Bangal...
 
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
 
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service AvailableCall Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
 
What’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 UpdateWhat’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 Update
 
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx PolandExtreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
 
Accelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAIAccelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAI
 
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptxSAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
 
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
 

FSOFT - Test Java Exam

  • 1. 1 JAVA TEST Time allowed: 30 minutes NAME: EMAIL: DATE:
  • 2. 2 Question# 1 Which of the following are keywords or reserved words in Java? A. if B. then C. goto D. while E. case Question# 2 A byte can be of what size A. -128 to 127 B. (-2 power 8)-1 to 2 power 8 C. -255 to 256 D. depends on the particular implementation of the Java Virtual machine Question# 3 What will happen if you try to compile and run the following code? public class Q { public static void main(String argv[]){ int anar[]=new int[]{1, 2, 3}; System.out.println(anar[1]); } } A. 1 B. Error anar is referenced before it is initialized C. 2 D. Error: size of array must be defined Question# 4 Given the following declarations String s1=new String("Hello"); String s2=new String("there"); String s3=new String(); Which of the following are legal operations? A. s3=s1 + s2; B. s3=s1 - s2; C. s3=s1 & s2; D. s3=s1 && s2
  • 3. 3 Question# 5 What will happen when you compile and run the following code? public class MyClass{ static int i; public static void main(String argv[]){ System.out.println(i); } } A. Error Variable i may not have been initialized B. null C. 1 D. 0 Question# 6 Which of the following statements are true? A. Methods cannot be overriden to be more private B. Static methods cannot be overloaded C. Private methods cannot be overloaded D. An overloaded method cannot throw exceptions not checked in the base class Question# 7 What will be the result of attempting to compile and run the following code? abstract class MineBase { abstract void amethod(); static int i; } public class Mine extends MineBase { public static void main(String argv[]){ int[] ar=new int[5]; for(i=0;i < ar.length;i++) } } A. a sequence of 5 0's will be printed B. Error: ar is used before it is initialized C. Error Mine must be declared abstract D. IndexOutOfBoundes Error
  • 4. 4 Question# 8 What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory? import java.io.*; public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); }catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; }catch(IOException ioe) { } finally{ System.out.println("Doing finally"); } return 0; } } A. No such file found B. No such file found, -1 C. No such file found, Doing finally, -1 D. 0 Question# 9 Which of the following statements are true? A. System.out.println(-1>>>2); will output a result larger than 10 B. System.out.println(-1>>>2); will output a positive number C. System.out.println(2>>1); will output the number 1 D. System.out.println(1<<<2); will output the number 4
  • 5. 5 Question# 10 What will be displayed when you attempt to compile and run the following code //Code start import java.awt.*; public class Butt extends Frame{ public static void main(String argv[]){ Butt MyBut=new Butt(); } Butt(){ Button HelloBut=new Button("Hello"); Button ByeBut=new Button("Bye"); add(HelloBut); add(ByeBut); setSize(300,300); setVisible(true); } } //Code end A. Two buttons side by side occupying all of the frame, Hello on the left and Bye on the right B. One button occupying the entire frame saying Hello C. One button occupying the entire frame saying Bye D. Two buttons at the top of the frame one saying Hello the other saying Bye Question# 12 - 11 If g is a graphics instance what will the following code draw on the screen? g.fillArc(45,90,50,50,90,180); A. An arc bounded by a box of height 45, width 90 with a centre point of 50, 50, starting at an angle of 90 degrees traversing through 180 degrees counter clockwise. B. An arc bounded by a box of height 50, width 50, with a centre point of 45, 90, starting at an angle of 90 degrees traversing through 180 degrees clockwise. C. An arc bounded by a box of height 50, width 50 with a top left at coordinates of 45, 90, starting at 90 degrees and traversing through 180 degrees counter clockwise. D. An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a box of height 50, width 50 with a centre point of 90, 180.
  • 6. 6 Question# 11 - 12 If you wanted to find out where the position of the letter v (ie return 2) in the string s containing "Java", which of the following could you use? A. mid(2,s); B. charAt(2); C. s.indexOf('v'); D. indexOf(s,'v'); Question# 13 What code placed after the comment //For loop would populate the elements of the array ia[] with values of the variable i.? public class Lin{ public static void main(String argv[]){ Lin l = new Lin(); l.amethod(); } public void amethod(){ int ia[] = new int[4]; //Start For loop { ia[i]=i; System.out.println(ia[i]); } } } A. for(int i=0; i < ia.length() -1; i++) B. for(int i=0; i < ia.length(); i++) C. for(int i=1; i < 4; i++) D. for(int i=0; i< ia.length;i++) Question# 15 - 14 An Applet has its Layout Manager set to the default of FlowLayout. What code would be correct to change to another Layout manager? A. set LayoutManager(new GridLayout()); B. set Layout(new GridLayout(2,2)); C. setGridLayout(2,2); D. setBorderLayout();
  • 7. 7 Question# 14 - 15 Which of the following will output -4.0 A. System.out.println(Math.floor(-4.7)); B. System.out.println(Math.round(-4.7)); C. System.out.println(Math.ceil(-4.7)); D. System.out.println(Math.min(-4.7)); Question# 16 What will be the result when you attempt to compile and run the following code? public class Conv{ public static void main(String argv[]){ Conv c=new Conv(); String s=new String("ello"); c.amethod(s); } public void amethod(String s){ char c='H'; c+=s; System.out.println(c); } } A. Compilation and output the string "Hello" B. Compilation and output the String "ello" C. Compilation and output the string elloH D. Compile time error Question# 23 - 17 What will the following code print out? public class Oct{ public static void main(String argv[]){ Oct o = new Oct(); o.amethod(); } public void amethod(){ int oi= 012; System.out.println(oi); } } A. 12 B. 012 C. 10 D. 10.0 Question# 17 - 18
  • 8. 8 What will be printed out if this code is run with the following command line? java Myprog good morning public class Myprog{ public static void main(String argv[]){ System.out.println(argv[2]) } } A. myprog B. good C. morning D. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2" Question# 18 - 19 If you create a TextField with a constructor to set it to occupy 5 columns, what difference will it make if you use it with a proportional font (ie Times Roman) or a fixed pitch typewriter style font (Courier) A. With a fixed font you will see 5 characters,with a proportional it will depend on the width of the characters B. With a fixed font you will see 5 characters,with a proportional it will cause the field to expand to fit the text C. The columns setting does not affect the number of characters displayed D. Both will show exactly 5 characters Question# 19 - 20 Given the following code: import java.awt.*; public class SetF extends Frame{ public static void main(String argv[]){ SetF s=new SetF(); s.setSize(300,200); s.setVisible(true); } } How could you set the frame su A. s.setBackground(Color.pink); B. s.setColor(PINK); C. s.Background(pink); D. s.color=Color.pink Question# 20 - 21 Given the following code what will be output?
  • 9. 9 public class Pass{ static int j=20; public static void main(String argv[]){ int i=10; Pass p = new Pass(); p.amethod(i); System.out.println(i); System.out.println(j); } public void amethod(int x){ x=x*2; j=j*2; } } A. Error: amethod parameter does not match variable B. 20 and 40 C. 10 and 40 D. 10, and 20 Question# 21 - 22 Which of the following can you perform using the File class? A. Change the current directory B. Return the name of the parent directory C. Delete a file D. Find if a file contains text or binary information Question# 24 - 23 What is the result of the following operation? System.out.println(4 | 3); A. 6 B. 0 C. 1 D. 7
  • 10. 10 Question# 22 - 24 What will be the result when you try to compile and run the following code? private class Base{ Base(){ int i = 100; System.out.println(i); } } public class Pri extends Base{ static int i = 200; public static void main(String argv[]){ Pri p = new Pri(); System.out.println(i); } } A. Error at compile time B. 200 C. 100 followed by 200 D. 100 Question# 25 What will happen when you try compiling and running this code? public class Ref{ public static void main(String argv[]){ Ref r = new Ref(); r.amethod(r); } public void amethod(Ref r){ int i=99; multi(r); System.out.println(i); } public void mult(Ref r){ r.i = r.i*2; } } A. Error at compile time B. An output of 99 C. An output of 198 D. An error at runtime Question# 27 - 26
  • 11. 11 Which of the following will compile without error? A. import java.awt.*; package Mypackage; class Myclass{} B. package MyPackage; import java.awt.*; class MyClass{} C. package MyPackage; importjava.awt.*; class MyClass{} Question# 28 - 27 Which of the following will successfully crate an instance of the Vector class and add an element? A. Vector v=new Vector(99); v[1]=99; C. Vector v=new Vector(); v.add(99); B. Vector v=new Vetor(); v.addElement(99); D. Vector v=new Vector(100); v.addElement("99"); Question# 29 - 28 What will happen when you compile and run the following code? public class Scope{ private int i; public static void main(String argv[])} Scope s = new Scope(); s.amethod(); }//End of main public static void amethod(){ System.out.println(i); }//end of amethod }//End of class A. A value of 0 will be printed out B. Nothing will be printed out C. A compile time error D. A compile time error complaining of the csope of the variable i Question# 26 - 29 What will be the result when you attempt to compile this program?
  • 12. 12 public class Rand{ public static void main(String argv[]){ int iRand; iRand = Math.random(); System.out.println(iRand); } } A. Compile time error referring to a cast problem B. A random number between 1 and 10 C. A random number between 0 and 1 D. A compile time error about random being an unrecognised method Question# 30 What will happen when you attempt to compile and run the following code class Base{ private void amethod(int iBase){ System.out.println("Base.amethod"); } } class Over extends Base{ public static void main(String argv[]){ Over o = new Over(); int iBase=0; o.amethod(iBase); } public void amethod(int iOver){ System.out.println("Over.amethod"); } } A. Runtime error complaining that Base.amethod is private B. Output of "Base.amethod" C. Output of "Over.amethod" D. Compile time error complaining that Base.amethod is private ~ The end ~
  翻译: