0% found this document useful (0 votes)
7 views2 pages

Java Practice Questions Anoop

The document contains a series of multiple-choice questions related to Java programming concepts, including loops, inheritance, data types, and output of code snippets. Each question presents options for answers, testing knowledge on Java syntax and behavior. The questions cover fundamental aspects of Java, making it suitable for beginners or those reviewing their understanding of the language.

Uploaded by

Anoop
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Java Practice Questions Anoop

The document contains a series of multiple-choice questions related to Java programming concepts, including loops, inheritance, data types, and output of code snippets. Each question presents options for answers, testing knowledge on Java syntax and behavior. The questions cover fundamental aspects of Java, making it suitable for beginners or those reviewing their understanding of the language.

Uploaded by

Anoop
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Consider the following code segment: for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 3; j++) {
[Link]("*"); } } How many times will '*' be printed?
A. 6
B. 9
C. 12
D. 16

2. What will be printed? class A { void show(){ [Link]("A "); } } class B extends A {
void show(){ [Link]("B "); } } A obj = new B(); [Link]();
A. A
B. B
C. Compilation Error
D. Runtime Error

3. What is the output? int x = 5; int y = 2; [Link](x / y);


A. 2

op
B. 2.5
C. 3
D. Compilation error

o
4. Which keyword is used to inherit a class in Java?
A. implement
B. inherits
An
C. extends
by
D. super

5. What is the size of an int in Java?


ed

A. 8 bits
B. 16 bits
C. 32 bits
ar

D. 64 bits
ep

6. Which of the following is not a primitive data type in Java?


A. int
Pr

B. float
C. String
D. boolean

7. What will be printed? String s = "Hello"; [Link]([Link]());


A. 3
B. 4
C. 5
D. 6

8. What is the output? for(int i=0;i<3;i++) [Link](i);


A. 012
B. 123
C. 001122
D. Compilation error

9. Which concept allows the same method name with different parameters?
A. Encapsulation
B. Polymorphism
C. Abstraction
D. Inheritance

10. What will be printed? [Link](10 % 3);


A. 1
B. 2
C. 3
D. 0

11. Which loop guarantees execution at least once?


A. for loop
B. while loop
C. do-while loop
D. enhanced for

12. What is the default value of a boolean variable?

op
A. true
B. false
C. 0

o
D. null

13. Which package contains the Scanner class?


A. [Link]
An
B. [Link]
by
C. [Link]
D. [Link]
ed

14. What will be printed? int a = 3; [Link](++a);


A. 3
B. 4
ar

C. 5
D. Compilation error
ep

15. Which access modifier provides the widest accessibility?


Pr

A. private
B. protected
C. default
D. public

You might also like