0% found this document useful (0 votes)
21 views

Java Conditional, Loops, Inheritence Quiz Questions

The document contains 25 multiple choice questions about Java concepts including conditionals, loops, inheritance. The questions cover topics such as constructors, overriding, polymorphism, encapsulation, and more.

Uploaded by

satya reddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Java Conditional, Loops, Inheritence Quiz Questions

The document contains 25 multiple choice questions about Java concepts including conditionals, loops, inheritance. The questions cover topics such as constructors, overriding, polymorphism, encapsulation, and more.

Uploaded by

satya reddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

NAME :

CLASS :
Java conditional,loops,inheritence
DATE :

25 Questions

1. What is the result?

a) valid b) not valid

c) Compilation fails d) An IllegalArgumentException is thrown at


run time

2.

a) 2 2 b) 2 3
c) 3 2 d) 3 3
3.

a) Maximum Speed: 150 b) Maximum Speed: 170


c) Maximum Speed: 0 d) error

4.

a) Furniture color... 5 ft ... b) Furniture color...chair color ... 5 ft ...


c) error
5. Which of this keyword can be used in a

subclass to call the constructor of


superclass?
a) super b) this

c) extends d) extent

6.

a) 0 b) 1

c) 2 d) compilation error
7.

a) 1 2 b) 2 2

c) 3 1 d) 2 1

e) 1 3

8.

a) 10 10 b) 10 20

c) 20 10 d) compilation error
The class that inherits an already

9.
defined class is called ___.

a) Subclass b) Superclass

10. You can not inherit a Superclass'es

constructor even after using


inheritance in Java. State TRUE or
FALSE.

a) TRUE b) FALSE

11.

a) B is superclass and A is subclass. b) There is no superclass or subclass


present.

c) A is superclass and B is a subclass. d) none


12.

a) Sweet=$10 Sweet=$10 Sweet=$20 b) Sweet=$10 Sweet=$20

c) Sweet=$20 Sweet=$10 d) Sweet=$20 Sweet=$20

13. What is the result if the integer aVar is 9?

a) 10 Hello Universe! b) 10 Hello World!

c) 9 Hello World! d) 9 Hello Universe!

14. Does the following class inherits some


other class?

a) YES b) NO
15. What will be the output of the program?

a) i = 1, j = 0 b) i = 1, j = 4

c) i = 3, j = 4 d) compilation error

16. String #name = "Jane Doe";int $age =

24;Double _height = 123.5;double ~temp =


37.5;
Which two statements are true ?

a) Line 1 will not compile. b) Line 2 will not compile.

c) Line 3 will not compile. d) Line 4 will not compile.

17.

a) a b c b) b c

c) a b d) Compilation fails.
18. In object oriented programming new

classes can be defined by extending


existing classes. This is an example of:

a) Encapsulation b) Interface

c) Inheritance d) Aggregation

e) constructor

19.

a) 2 3 b) 2 2

c) 3 3 d) run time error

e) Compilation Error

20.

a) 10 b) 11

c) 12 d) 13
21. Hiding internal data from outside world

and accessing it only through publicly


exposed methods is known as ___________

a) Inheritance. b) Duplication.

c) Polymorphism d) Encapsulation.

22.

a) 30 b) 20

c) 10 d) compile time error

23. All the variables of interface should be?

a) default and final b) default and static

c) public ,static and final d) all the above

24. Advantage(s) of inheritance in Java

programming is/are

a) Code readability b) two classes (base and inherited class) get


tightly coupled

c) Code maintainability d) Code reusability


25.

a) Hello b) There will be a compile-time error.

c) Program will compile successfully. d) The program will give a runtime error.
Answer Key
1. c 8. d 15. d 22. d
2. a 9. a 16. a,d 23. c
3. a 10. a 17. b 24. a,c,d
4. a 11. b 18. c 25. c,d
5. a 12. b 19. a
6. c 13. b 20. d
7. a 14. a 21. d

You might also like