You are on page 1of 15

1. What are the types of memory allocated in memory in java?

A. Heap memory
B. Stack memory
C. Both A and B
D. None of these

2. What will be the output of following Java code?

public class Main {


public static void main(String arg[]) {
int i;
for (i = 1; i <= 12; i += 2) {
if (i == 8) {
System.out.println(i);
break;
}

A. 1
B. No output
C. 8
D. 1357911

3. Which of these is the correct method to create an array in java?

A. int[] arr = {1, 3, 5};


B. int[] arr;
C. arr = new int[] {3, 1, 8};
D. int arr[] = {1, 4, 6};
E. All of these

4. 'this' keyword in java is ___.

A.Used to hold the reference of the current B.object


C.Holds object value
D.Used to create a new instance
E.All of these

5. Which among the following is a Logical Unary NOT operator in


Java?
A) ~
B) !
C) #
D) ^

6. What is the output of the Java code snippet?

boolean b=false;

b = !b;

System.out.println(b);

A) true

B) false

C) Compiler error

D) None of the above

7. Choose correct examples of decimal literals in Java.


A)

int a = 12345;

B)

int a = 12_3__5;

C)

long a = 987____654_3__21L;

D) All the above

8. What is the output of the code snippet with the ternary operator?

int p=5;

System.out.print("Hello ");

(p<6)?5:6;

A) Hello 5

B) Hello 6

C) Hello

D) Compiler error

9. What is the output of the Java code snippet with Ternary operator?

String name = "java";

int marks = name == "java"?10:20;

System.out.println("Marks=" + marks);

A) marks=0
B) marks=10

C) marks=20

D) Compiler error

10. What is the output of the below Java program?

public class TestingConstructor

void TestingConstructor()

System.out.println("Amsterdam");

TestingConstructor()

System.out.println("Antarctica");

public static void main(String[] args)

TestingConstructor tc = new TestingConstructor();

}
}

A) Antarctica

B) Amsterdam

C) No output

D) Compiler error

11. What is the output of the below Java program?

int a=1;

while(a<4)

System.out.print(a + " ");

a++;

A) 1 2 3 4

B) 1 2 3

C) 6

D) Compiler error

12. What is the output of the below Java program with WHILE, BREAK
and CONTINUE?

int cnt=0;

while(true)
{

if(cnt > 4)

break;

if(cnt==0)

cnt++;

continue;

System.out.print(cnt + ",");

cnt++;

A) 0,1,2,3,4,

B) 1,2,3,4,

C) 1,2,3,4

D) Compiler error

13. What is the output of the below java program that implements
nesting of loops?

int i=1, j=1;

while(i<3)

{
do

System.out.print(j + ",");

j++;

}while(j<4);

i++;

A) 1,2,3,4,1,2,3,4,

B) 1,2,3,4,

C) 1,2,3,1,2,3,

D) 1,2,3,

14. What is the output of the Java program with Enhanced FOR loop
below?

String countries[] = {"BRAZIL", "CHILE", "SYDNEY"};

int i=0;

for(String str: countries)

if(i<2)

else
break;

System.out.print(str + ",");

i++;

A) BRAZIL,CHILE,SYDNEY,

B) BRAZIL,CHILE,

C) BRAZIL,

D) Compiler error

15. What is the output of the below java program with Constructors
and Inheritance?

class Processor

Processor()

System.out.print("Inside Processor() Constructor. ");

class I3Processor extends Processor

I3Processor()
{

System.out.print("Inside I3Processor() Constructor. ");

class I5Processor extends I3Processor

I5Processor()

System.out.print("Inside I5Processor() Constructor. ");

public class JavaInheritance2

public static void main(String[] args)

I5Processor i5 = new I5Processor();

}
A) Inside I5Processor() Constructor. Inside I3Processor() Constructor.
Inside Processor() Constructor.

B) Inside I5Processor() Constructor. Inside I5Processor() Constructor.


Inside I5Processor() Constructor.

C) Inside Processor() Constructor. Inside I3Processor() Constructor.


Inside I5Processor() Constructor.

D) Compiler error

16. A Van of robbers is noticed by a Cop from a distance of 200 m. The


robbers leave the van and start running and the cop chases them. The
robbers and the cop run at the rate of 10 km and 11 km per hour
respectively. After 6 minutes what will be the distance between them?

A.50 Meter

B.100 Meter

C.110 Meter

D.None Of The Above

17. A man is swimming in a stream which flows at the rate of 1.5


kmph. In a given time he can swim twice the distance with the stream
as compared to the distance he can swim against it. Find the speed of
the man.

A) 7.5 kmph
B) 9.5 kmph
C) 5.5 kmph
D) 3.5 kmph
E) 4.5 kmph
18. A boy is walking at a speed of 10 km/h along a railway track. If he
is 800 m ahead of the train which is 400 m long and runs at a speed of
160 km/h in the same direction, then what is the time required to
pass a boy?

A) 15.2 sec
B) 18.3 sec
C) 12.5 sec
D) 28.8 sec
E) 8.6 sec

19. The length of train A is 25% more than that of train B and the
speed of train A is 20% more than that of B. If train A crosses a tree in
12 seconds and also crosses train B running in the same direction in
162 seconds, then find the speed of train B.

A) 100 kmph
B) 60 kmph
C) 90 kmph
D) 50 kmph
E) Cannot be determined

20. Rs, 2400 was invested for 3 years, partly in scheme A at the rate
15% S.I per annum and partly at the rate of 10% S.I per annum. Total
interest received at the end was Rs.930. How much sum of money
was invested in scheme A?

A. Rs.1500
B. Rs.1000
C. Rs.1200
D. Rs.1400
E. Rs.1900

21. There is 80% increase in an amount in 8 years at simple interest.


What will be the compound interest of Rs. 15,000 after 3 years at the
same rate of interest?

A. Rs. 4,965
B. Rs. 5,500
C. Rs. 4,700
D. Rs. 4,265
E. Rs. 5,865

22. If the sum of two numbers is 42 and their product is 437, then find
the absolute difference between the numbers.

A. 4
B. 6
C. 8
D. 12
E. None

23. A boy multiplied 987 by a certain number and obtained 559981 as


his answer. If in the answer both 98 are wrong and the other digits are
correct , then the correct answer would be:

A. 553681
B. 555181
C. 555681
D. 556581
E. None

24. A sum of money lent at compound interest for 2 years at 20% per
annum would fetch Rs.96.4 more, if the interest was payable half
yearly, then find the sum?

A. Rs. 2,000
B. Rs. 2,500
C. Rs. 3,750
D. Rs. 4,250
E. Rs 4,000

25. The compound interest accrued on an amount at the end of 3


years at the rate of 20% per annum is Rs.5824. What is the Principal?

A. Rs.8000
B. Rs.9000
C. Rs.7500
D. Rs.10000
E. Rs.15000

26. A invests some amount in a business. After 6 months his friend B


joined him with the triple amount that A invests in starting of
business. If in the business the total profit earned by both of them is
Rs.16480, then find the difference between the share of profit
between A and B

A. 4296 RS.
B. 3296 RS.
C. 3290 RS.
D. 6396 RS.
E. 2396 RS.

27. The sum of the speed of boat and stream in downstream and
upstream is 56km/h and the time taken by boat in upstream is 45min
whereas in downstream is 30min. find the difference between the
distance travelled in upstream and downstream if the speed of stream
is 4km/hr.

a) 5km
b) 2km
c) 6km
d) 7km
e) 8km

28. men and 5 women together can complete the work in 5 days and 4
men and 4 women can complete the work in 8 days. In how many
days 2 men and 2 women can complete the work?

A. 18 days
B. 8 days
C. 12 days
D. 16 days
E. 17 days

29. Arun alone can do a piece of work in 15 days. Rahul can do the
same piece of work in 12 days. Arun and Rahul are assigned to do the
work for Rs. 1250. They complete the work in 6 days with the help of
Ranjan. How much is to be paid to Ranjan?
A. Rs. 150
B. Rs. 125
C. Rs. 175
D. Rs. 225
E. Rs. 275

30. The circumference of a circle is equal to the perimeter of a square.


The side of the square is 55 cm. What is double the diameter of the
circle?

A. 35 cm
B. 120 cm
C. 140 cm
D. 84 cm
E. 70 cm

You might also like