22412 JAVA PROGRAMMING MCQ QB 1
Unit 3: Inheritance, Interface, and Package
4th SEM ALL SUBJECT MCQ: click here
1. What are the features of an Object Oriented Programming (OOPs)?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) All the above
2. What are the features reused using Inheritance in Java?
A) Methods
B) Variables
C) Constants
D) All the above
3. The class that is being inherited or subclassed is called ___.
A) Subclass
B) Superclass
C) -
D) -
4. The class that inherits an already defined class is called ___.
A) Subclass
B) Superclass
C) -
D) -
5. Java language supports ___ type of inheritance.
A) Multiple Inheritance
B) Multi-Level Inheritance
C) -
D) -
6. ………………… is one of the cornerstones of object-oriented programming because it allows the creation of hierarchical classifications.
A) Mutual Exclusion
B) Inheritance
C) Package
D) Interface
7. ……………….. helps to extend the functionality of an existing by adding more methods to the subclass.
A) Mutual Exclusion
B) Inheritance
C) Package
D) Interface
8. The variables, methods, and inner classes that are declared ………………… are accessible to the sub-classes of the class in which they are declared.
A) private
B) public
C) protected
D) friend
9. State whether the following statements about the advantages of organizing classes into packages are True or False.
i) Two classes in two different packages can not have the same name.
ii) The classes contained in the packages of other programs can be easily reused.
A) True, False
B) False, True
C) True, True
D) False, False
10. ………………….. package in java contents language utility classes such as vectors, hash tables, random numbers date etc.
A) java.util
B) java.awt
C) java.net
D) java.lang
11. …………………….. package in java contents set of classes for implementing graphical user interface, which includes classes for windows, buttons, lists, menus and so on.
A) java.util
B) java.awt
C) java.net
D) java.lang
12. State whether the following statements are True or False.
i) When present, the package must be the first non-comment statement in the file.
ii) When we implement an interface method, it should be declared as public.
A) True, False
B) False, True
C) True, True
D) False, False
13. Which keyword can protect a class in a package from accessibility by the classes outside the package?
i) private ii) protected iii) final
A) i only
B) ii only
C) iii only
D) None of the above
14. A package is a collection of
A) Classes
B) interfaces
C) editing tools
D) classes and interfaces
15. Package P1 contains the following code
package P1;
public class student {Body of Student}
Class Test {Body of Test}
Now consider the following code;
import P1.*;
Class Result{
student S1;
Test t1;
}
This code compile because
A) Class result should be declared public.
B) Student class is not available
C) Test class is not available
D) Result body is not fully defined
16. Which of the following classes in the Java.io package defines a method to delete a file.
A) Stack
B) File
C) String
D) Vector
17. For a valid file object reference, we can create a new file using the following classes defined in the Java.io package.
i) FileOutputStream
ii) RandomAccessFile
iii) DataInput
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii
18. The Date class includes within ………………….. package.
A) java.io
B) java.awt
C) java.net
D) java.util
19. Which of the following classes are included in java.awt package.
i) Font ii) Frame iii) Float iv) File
A) i and ii only
B) ii and iii only
C) iii and iv only
D) i and iv only
20. Which of the following sub-classes are included in object class in Java.
i) Dictionary ii) Date iii) Label iv) Thread
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) i, ii and iv only
21. An …………………. is an incomplete class that requires further specification.
A) abstract class
B) final class
C) static class
D) super class
22. A class can be declared as ………………………. if you do not want the class to be subclassed.
A) abstract
B) final
C) static
D) super
23. The …………………….. keyword is used to derive a class from a super-class.
A) adds
B) extends
C) duplicate
D) inherit
24. If a class that implements an interface does not implement all the methods of the interface, then the class becomes a/an …………………….. class.
A) abstract
B) final
C) static
D) super
25. By convention, java packages begin with ………………. letters while all the class names begin with an ………………… letter.
A) uppercase, uppercase
B) lowercase, lowercase
C) uppercase, lowercase
D) lowercase, uppercase
Happy Learning!
Comments
Post a Comment
If you have any query, please let us know