SlideShare a Scribd company logo
1 of 12
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

Chương 4. Chuẩn hóa cơ sở dữ liệu
Chương 4. Chuẩn hóa cơ sở dữ liệu Chương 4. Chuẩn hóa cơ sở dữ liệu
Chương 4. Chuẩn hóa cơ sở dữ liệu Hoa Le
 
Ứng dụng chát realtime android
Ứng dụng chát realtime androidỨng dụng chát realtime android
Ứng dụng chát realtime androidNguyen Thieu
 
Ôn thi mạng máy tính
Ôn thi mạng máy tínhÔn thi mạng máy tính
Ôn thi mạng máy tínhKinhDinhBach
 
Tài liệu lập trình PHP từ căn bản đến nâng cao
Tài liệu lập trình PHP từ căn bản đến nâng caoTài liệu lập trình PHP từ căn bản đến nâng cao
Tài liệu lập trình PHP từ căn bản đến nâng caoZendVN
 
Bo de toan roi rac (on thi cao hoc khmt)
Bo de toan roi rac (on thi cao hoc khmt)Bo de toan roi rac (on thi cao hoc khmt)
Bo de toan roi rac (on thi cao hoc khmt)lieu_lamlam
 
Giáo trình xử lý ảnh
Giáo trình xử lý ảnhGiáo trình xử lý ảnh
Giáo trình xử lý ảnhTùng Trần
 
Bài giảng Lập trình mạng
Bài giảng Lập trình mạngBài giảng Lập trình mạng
Bài giảng Lập trình mạngctrl man
 
Bai tap va loi giai sql
Bai tap va loi giai sqlBai tap va loi giai sql
Bai tap va loi giai sql. .
 
Bài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPT
Bài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPTBài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPT
Bài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPTMasterCode.vn
 
Hệ thống quản lý bán hàng online
Hệ thống quản lý bán hàng onlineHệ thống quản lý bán hàng online
Hệ thống quản lý bán hàng onlineHan Nguyen
 
Tong hop cau hoi trac nghiem hdh
Tong hop cau hoi trac nghiem hdhTong hop cau hoi trac nghiem hdh
Tong hop cau hoi trac nghiem hdhHoat Thai Van
 
De thi qlda cntt itc vdc trac nghiem 05-2006
De thi qlda cntt itc vdc trac nghiem 05-2006De thi qlda cntt itc vdc trac nghiem 05-2006
De thi qlda cntt itc vdc trac nghiem 05-2006Tran Tien
 
Đảm bảo chất lượng phầm mềm (nguồn PTIT)
Đảm bảo chất lượng phầm mềm (nguồn PTIT)Đảm bảo chất lượng phầm mềm (nguồn PTIT)
Đảm bảo chất lượng phầm mềm (nguồn PTIT)Thuyet Nguyen
 
UML mô hình khái niệm
UML mô hình khái niệmUML mô hình khái niệm
UML mô hình khái niệmNguyễn Phúc
 
Phân tích và thiết kế hệ thống quản lý bán hàng
Phân tích và thiết kế hệ thống quản lý bán hàngPhân tích và thiết kế hệ thống quản lý bán hàng
Phân tích và thiết kế hệ thống quản lý bán hàngleemindinh
 
Các giao thức sử dụng trong các lớp của mô hình osi
Các giao thức sử dụng trong các lớp của mô hình osiCác giao thức sử dụng trong các lớp của mô hình osi
Các giao thức sử dụng trong các lớp của mô hình osiUDCNTT
 
Phụ thuộc hàm và dạng chuẩn 1
Phụ thuộc hàm và dạng chuẩn 1Phụ thuộc hàm và dạng chuẩn 1
Phụ thuộc hàm và dạng chuẩn 1Trung Trần
 

What's hot (20)

Chương 4. Chuẩn hóa cơ sở dữ liệu
Chương 4. Chuẩn hóa cơ sở dữ liệu Chương 4. Chuẩn hóa cơ sở dữ liệu
Chương 4. Chuẩn hóa cơ sở dữ liệu
 
Ứng dụng chát realtime android
Ứng dụng chát realtime androidỨng dụng chát realtime android
Ứng dụng chát realtime android
 
Ôn thi mạng máy tính
Ôn thi mạng máy tínhÔn thi mạng máy tính
Ôn thi mạng máy tính
 
Tài liệu lập trình PHP từ căn bản đến nâng cao
Tài liệu lập trình PHP từ căn bản đến nâng caoTài liệu lập trình PHP từ căn bản đến nâng cao
Tài liệu lập trình PHP từ căn bản đến nâng cao
 
Bo de toan roi rac (on thi cao hoc khmt)
Bo de toan roi rac (on thi cao hoc khmt)Bo de toan roi rac (on thi cao hoc khmt)
Bo de toan roi rac (on thi cao hoc khmt)
 
Giáo trình xử lý ảnh
Giáo trình xử lý ảnhGiáo trình xử lý ảnh
Giáo trình xử lý ảnh
 
Hệ mật mã Elgamal
Hệ mật mã ElgamalHệ mật mã Elgamal
Hệ mật mã Elgamal
 
Đề tài: Xây dựng ứng dụng Android đọc báo mạng qua dịch vụ RSS
Đề tài: Xây dựng ứng dụng Android đọc báo mạng qua dịch vụ RSSĐề tài: Xây dựng ứng dụng Android đọc báo mạng qua dịch vụ RSS
Đề tài: Xây dựng ứng dụng Android đọc báo mạng qua dịch vụ RSS
 
Bài giảng Lập trình mạng
Bài giảng Lập trình mạngBài giảng Lập trình mạng
Bài giảng Lập trình mạng
 
Bai tap va loi giai sql
Bai tap va loi giai sqlBai tap va loi giai sql
Bai tap va loi giai sql
 
Bài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPT
Bài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPTBài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPT
Bài 7 Xây dựng website sử dụng PHP và MySQL - Giáo trình FPT
 
Hệ thống quản lý bán hàng online
Hệ thống quản lý bán hàng onlineHệ thống quản lý bán hàng online
Hệ thống quản lý bán hàng online
 
Tong hop cau hoi trac nghiem hdh
Tong hop cau hoi trac nghiem hdhTong hop cau hoi trac nghiem hdh
Tong hop cau hoi trac nghiem hdh
 
De thi qlda cntt itc vdc trac nghiem 05-2006
De thi qlda cntt itc vdc trac nghiem 05-2006De thi qlda cntt itc vdc trac nghiem 05-2006
De thi qlda cntt itc vdc trac nghiem 05-2006
 
Đảm bảo chất lượng phầm mềm (nguồn PTIT)
Đảm bảo chất lượng phầm mềm (nguồn PTIT)Đảm bảo chất lượng phầm mềm (nguồn PTIT)
Đảm bảo chất lượng phầm mềm (nguồn PTIT)
 
Chia subnetmask
Chia subnetmaskChia subnetmask
Chia subnetmask
 
UML mô hình khái niệm
UML mô hình khái niệmUML mô hình khái niệm
UML mô hình khái niệm
 
Phân tích và thiết kế hệ thống quản lý bán hàng
Phân tích và thiết kế hệ thống quản lý bán hàngPhân tích và thiết kế hệ thống quản lý bán hàng
Phân tích và thiết kế hệ thống quản lý bán hàng
 
Các giao thức sử dụng trong các lớp của mô hình osi
Các giao thức sử dụng trong các lớp của mô hình osiCác giao thức sử dụng trong các lớp của mô hình osi
Các giao thức sử dụng trong các lớp của mô hình osi
 
Phụ thuộc hàm và dạng chuẩn 1
Phụ thuộc hàm và dạng chuẩn 1Phụ thuộc hàm và dạng chuẩn 1
Phụ thuộc hàm và dạng chuẩn 1
 

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 professionalIsabella789
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSESujata 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.pdfVedant Gavhane
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and AnswersRumman Ansari
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmerMiguel Vilaca
 
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 iiIsabella789
 
Computer science ms
Computer science msComputer science ms
Computer science msB Bhuvanesh
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfahmed8651
 
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, TuningCarol McDonald
 
Redo midterm
Redo midtermRedo midterm
Redo midtermIIUM
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomeshpraveensomesh
 
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

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 

Recently uploaded (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

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 ~