Monday 2 April 2012

MCQ - Basics Of Java


MCQ

1.  A good reason to use an object – oriented language is that. :

A. You can define your data type
B. program statements are simpler than in procedural languages
C. an object – oriented program can correct its own mistakes
D. it is easier to conceptualize an object-oriented program and reuse code.

2. Sharing of common information is achieved by concept of :
A. polymorphism
B. encapsulation
C. inheritance
D. none of above

3.Java was first developed in ____
A. 1990
B. 1991
C. 1993
D. 1996

4. The old name of java was ____
A. J language
B. Oak
C. Ock
D. none of above

5. full form of ADT is ____
A. Abstract Definition Type
B. Abstract Data Type
C. Abstraction Data Type
D. Abstract Data Toolkit

6. Full form of JVM is ____
A. Java Virtual Mechanism
B. Java Variable machine
C. Java Virtual Machine
D. Java variable Mechanism

7. Full form of JDK is _____
A. Java Development Kit
B. Java Definition Kit
C. Java Data Kit
D. Java Declaration Kit

8. To compile a java program ____ command is used
A. javac
B. java
C. javad
D.javadoc

9. Which of the following is a valid main() method?

A. public static void main()
B. public static void main(String s[])
C. void main(String args[])
D. none of above

10. When source file is successfully compiled , ____ is generated
A. output
B. bytecode
C. error
D. none of above

11. From these which one is the compulsory section in a java program?
A. Package statement
B. Import statement
C. Documentation section
D. Class declaration section

12. Java compiled programs have ______ extension
A. .java
B.   .source
C. .compile
D. .class

13. Which of the following is valid java comment?
A. \\ this is a comment
B. /* This is a comment */
C. /** This is a comment
D. \* This is a comment *\


14. Which is the valid identifier from following
A. $rate
B. Discount%
C.Number.1
D.First-Rank

15. Which one of these lists contains only Java programming language keywords?

A. class, if, void, long, Int, continue
B. goto, instanceof, native, finally, default, throws
C. try, virtual, throw, final, volatile, transient
D. strictfp, constant, super, implements, do

16.Which of the following is a primitive data types?
A.byte
B.String
C.integer
D.Float

17.To create an array of 5 integers which statement is correct
A. int a[]=int [5]

B. int a[5]=new a[]
C. int a[]=new int [5]
D. int a[]=new a[5]

18. In java , if you do not give a value to a variable before using it ,______
A. It will contain a garbage value
B. It will initialized with zero
C. Compiler will give an error
D. None of above

19.What is the value of expression 9+8%7+6?
A. 17
B. 16
C. 13
D. 4

20. if a=10 and b=20 then a++ +--b=_____
A. 30
B. 29
C. 31
D.32

21. Relational operations returns a ____ value.
A. int
B. char
C. float
D. Boolean

22. Bitwise operators are used with ____ type of operands
A. integer
B. float
C. boolean
D. Any of these

23. 10 & 11 =___
A. 21
B.11
C. 10
D. 9

24.The instanceof operator returns a ____ value
A. Boolean
B. char
C. int
D. byte

25.The character literal represents ____ Unicode character
A. 8 bit
B. 16 bit
C. 32 bit
C. 64 bit

26. A variable defined within a block is visible _____
A. From the point of definition onwards in the program
B. From the point of definition onwards in the function
C. from the point of definition onwards in the block
C. none of above


27. From the following which is not a branching statement.
A. if
B. switch
C. while
D. if else ladder

28. In switch case if a matching case is not found___ is executed
A. else
B. break
C. default
D. none of these
29.Which of the following loop is exit- controlled loop?
A. while
B. do while
C. for
All of these



30. for(i=1,j=0;i<10;i++)
       j +=i;
    System.out.println(i);

A. 10
B. 11
C. 55
D.45


Answers:

1
- D
2
- C
3
- B
4
- B
5
- C
6
- C
7
- A
8
- A
9
- B
10
- B
11
- D
12
- D
13
- B
14
- B
15
- B
16
- A
17
- C
18
- C
19
- B
20
- B
21
- D
22
- A
23
- C
24
- A
25
- B
26
- C
27
- C
28
- C
29
- B
30
- A


Posted By : Ruchita Pandya

3 comments: