JAVA 19

COEP
Lets Crack Online Exam

IT Interview Exam Questions: JAVA 19 (IT Campus Placement)

Subject: JAVA 19

Part 19: List for questions and answers of JAVA

 

Q1. Which of these function is used to allocate memory to array variable in Java?

a) malloc

b) alloc

c) new

d) calloc

 

Q2. Which of these is necessary to specify at time of array initialization?

a) Row

b) Column

c) Both Row and Column

d) None of the mentioned

 

Q3. What will be printed using following code block?

int[] a = {0,1,2,3,4,5,6,7};

System.out.println(a.length);

a) 6

b) 7

c) 8

d) 9

 

Q4. What will happen when following Java code block is compiled and run?

public class A 

     public static void main(String argv[])

    { int ary[]=new int[] {1,2,3};

     System.out.println(ary[1]); 

    }

}

a) 1

b) Compilation Error: Incorrect Syntax

c) 2

d) Compilation Error: size of array must be defined

 

Q5. What will happen if following code block is compiled/run?

int[] iArray = new int[10];

iArray.length = 15;

System.out.println(iArray.length);

a) Prints 10

b) Prints 15

c) Compilation Error

d) Run Time Error 

 

Q6. Select the one correct answer

a) arr.length

b) arr.length-1

c) arr.size

d) arr.size-1

 

Q7. Arrays in Java are implemented as?

a) class

b) object

c) variable

d) None of the mentioned

 

Q8. Which of the following statements are valid array declaration ?

(A)int number();

(B)float average[];

(C)double[] marks;

(D)counter int[];

a) (A)

b) (A)&(C)

c) (B)&(C)

d) (D)

 

Q9. int number[] = new int[5]; After execution of this statement, which of the following are true?

(A)number[0] is undefined

(B)number[5] is undefined

(C)number[4] is null

(D)number[2] is 0

(E)number.length() is 5

a) (A)&(E)

b) (C)&(E)

c) (E)

d) (B),(D)&(E)

 

Q10. Which one of the following will declare an array and initialize it with five numbers?

a) Array a = new Array(5);

b) int [] a = {23,22,21,20,19};

c) int a [] = new int[5];

d) int [5] array; 

 

Q11. Which three are legal array declarations?

1.int[]myScores [];

2.char[]myChars;

3.int[6]myScores;

4.Dog myDogs[];

5.Dog myDogs[7];

a) 1,2,4

b) 2,4,5

c) 2,3,4

d) All are correct

 

Q12. Which of the following statements are valid array declarations?

A.int number();

B.int number[];

C.double[]marks;

D.counter int[];

a) A,B,C

b) B,C

c) C,D

d) A,B,D

 

Q13. What will be output using following code block?

int[] a = {0,1,2,3,4,5,6,7};

System.out.println(a.length);

a) 6

b) 7

c) 8

d) 9

 

Q14. Arrays in Java are implemented as?

a) class

b) object

c) variable

d) None of the mentioned

 

Q15. Which of these keywords is used to prevent content of a variable from being modified?

a) final

b) last

c) constant

d) static 

 

Q16. Which of these cannot be declared static?

a) class

b) object

c) variable

d) method

 

Q17. Which of the following statements are incorrect?

a) static methods can call other static methods only

b) static methods must only access static data

c) static methods can not refer to this or super in any way

d) when object of class is declared, each object contains its own copy of static variables

 

Q18. Which of the following statements are incorrect?

a) Variables declared as final occupy memory

b) final variable must be initialized at the time of declaration

c) Arrays in java are implemented as an object

d) All arrays contain an attribute-length which contains the number of elements stored in the array

 

Q19. Which of these methods must be made static?

a) main()

b) delete()

c) run()

d) finalize()

 

Q20. Which of these is necessary to specify at time of array initialization?

a) Row

b) Column

c) Both Row and Column

d) None of the mentioned 

 

Part 19: List for questions and answers of JAVA

 

Q1. Answer: c

 

Q2. Answer: a

 

Q3. Answer: c

 

Q4. Answer: c

 

Q5. Answer: c

 

Q6. Answer: a

 

Q7. Answer: b

 

Q8. Answer: c

 

Q9. Answer: d

 

Q10. Answer: b

 

Q11. Answer: a

 

Q12. Answer: b

 

Q13. Answer: c

 

Q14. Answer: b

 

Q15. Answer: a

 

Q16. Answer: b

 

Q17. Answer: d

 

Q18. Answer: a

 

Q19. Answer: a

 

Q20. Answer: a