To Prepare Model Exam OOP Question
To Prepare Model Exam OOP Question
To Prepare Model Exam OOP Question
1. Which translator the individual steps in a high-level program one at a time rather than the
whole program as a single unit.
a) Interpreter
b) Assembler
c) Compiler
d) JVM
e) All
2. It is based on commands that update variables in storage and control flow is an explicit
sequence of commands.
a) Imperative or procedural
b) Declarative
c) Logical or rule based
d) Functional
e) None
3. What is procedure-oriented Language?
a) A procedure-oriented Language is a language that incorporates all object-oriented
programming features
b) A procedure-oriented Language is a language that supports encapsulation and object
identity
c) A procedure-oriented Language is a language that consists of writing a list of
instructions
d) A procedure-oriented Language is a language that does not support Inheritance and
Dynamic binding
4. Which one is false about java Key features?
a) Platform-independent
b) Simple
c) Centralize
d) Portable
e) Multithreaded
5. Which one is not java identifiers
a) intab
b) _ab
c) All are possible
d) a-bc
e) a$b
6. Which one is true about Java platform
a) JRE is a superset of the JDK
b) JRE = JVM + Java Packages of Classes+ runtime libraries
c) JDK is a superset of the JRE
d) All are correct
7. Which converted type is Casting with a larger range to a type with a small range
a) Narrowing a type
b) Widening a type
c) Explicit casting
To prepare model exam
1
d) Implicit casting
8. Which one is false about while and do while loop
a) Bothe are the same syntax
b) While loop syntax first execute then check the expression
c) Do While loop syntax first check the expression then execute
d) All are false
e) All are true
9. int x=3;
a) 5
b) 0
c) 6
d) None
11. Which was the first purely object oriented programming language developed?
a) Kotlin
b) SmallTalk
c) Java
d) C++
12. Which feature of OOP indicates code reusability?
a) Abstraction
b) Polymorphism
c) Encapsulation
d) Inheritance
13. Which among the following doesn’t come under OOP concept?
a) Data hiding
b) Message passing
c) Platform independent
d) Data binding
14. Which is the correct syntax of inheritance?
a) class base_classname extends derived_classname{ /*define class body*/ };
b) class derived_classname extends base_classname{ /*define class body*/ };
c) class derived_classname base_classname{ /*define class body*/ };
d) class base_classname derived_classname{ /*define class body*/ };
20. Which one is true about to Creating Two-Dimensional Arrays(3 row and 4 column) the
array reference variable is List and the element type is Double
a) double list[][]= double[3][4];
b) double[][] list= new double[3][4];
c) double [][] list= new double[4][3];
d) double list[][]= new[4][3]double;
21. Which one is true to assign the value 5.5 on the * place the array reference variable is List
a) list[3][2]=5.5;
* b) list[2][3]=5.5;
c) list[1][2]=5.5;
d) list[2][1]=5.5;
22. Which of the following statements is false?
a) A public class can be accessed by a class from a different package.
b) A private method cannot be accessed by a class in a different package.
c) A protected method can be accessed by a subclass in a different package.
d) A method with default modifier can be accessed by a class in a different package
23. What is the output of the following code?
24. Which of the following modifier is not accessible in another class in different package
but is accessible to any subclasses in any package?
a) public
class A
{
int i;
A()
{
i=0; cout<<i;
}
A(int x=0)
{
i=x; cout<<I;
}
};
A obj1;
a) Parameterized constructor
b) Default constructor
c) Run time error
d) Compile time error
28. What is an abstraction in object-oriented programming?
a) Hiding the implementation and showing only the features
b) Hiding the important data
c) Hiding the implementation
d) Showing the important data
29. In which access should a constructor be defined, so that object of the class can be created in
any function?
a) Any access specifier will work
b) Private
c) Public
d) Protected
30. Which among the following is correct for the class defined below?
class student
{
int marks;
5
public: student(){}
student(int x)
{
marks=x;
}
};
main()
{
student s1(100);
student s2();
student s3=100;
return 0; }
class A
{
int i;
A()
{
i=0;
}
A(int x)
{
i=x+1;
}
A(int y, int x)
{
i=x+y;
}
};
A obj1(10);
A obj2(10,20);
A obj3;
a) A(int y, int x)
b) A(int y; int x)
c) A(int y)
d) A(int x)
7
c) Computer Science.java
d) SectionF.java
e) None
B. class of Section
class of Computing Faculty
class of IT
C. class of Section
class of IT
class of Computing Faculty
D. None
41. Which one of the following is false statement about the object created by Section obj =
new Section();
a) obj instanceof ComputingFaculity
b) obj instanceof IT
c) obj instanceof Section
d) obj instanceof ComputerScience
e) None
8
42 How to access data members of a class?
a) Dot, arrow or direct call
b) Dot operator
c) Arrow operator
d) Dot or arrow as required
43. Which keyword among the following can be used to create an array of objects in java?
a) allocate
b) arr
c) new
d) create
44. Which of the following is not a property of an object?
a) Properties
b) Names
c) Identity
d) Attributes
45. Which type of members can’t be accessed in derived classes of a base class?
a) All can be accessed
b) Protected
c) Private
d) Public
46. Which among the following best describes the Inheritance?
a) Using the data and functions into derived segment
b) Using already defined functions in a programming language
c) Using the code already written once
d) Copying the code already written
47. What happens if non static members are used in static member function?
a) Executes fine
b) Compile time error
c) Executes if that member function is not used
d) Runtime error
48. Where is the memory allocated for the objects?
a) Cache
b) ROM
c) HDD
d) RAM
9
c) Hiding and Binding respectively
d) Can be used any way
51. Which feature of OOP is exhibited by the function overriding?
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
52. How to access the private member function of a class?
a) Using class address
b) Using object of class
c) Using object pointer
d) Using address of member function
53. Which keyword should be used to declare static variables?
a) const
b) common
c) static
d) stat
54. Which is correct syntax for declaring pointer to object?
a) *className objectName;
b) className* objectName;
c) className objectName();
d) className objectName;
55. Which class/set of classes can illustrate polymorphism in the following C++ code?
10
c) Create private member functions to access those data members
d) Create protected member functions to access those data members
57. Which among the following is not a necessary condition for constructors?
a) Its name must be same as that of class
b) It must not have any return type
c) It must contain a definition body
d) It can contains arguments
58. Object being passed to a copy constructor ___________
a) Must not be mentioned in parameter list
b) Must be passed with integer type
c) Must be passed by value
d) Must be passed by reference
59. If in multiple inheritance, class C inherits class B, and Class B inherits class A. In which
sequence are their destructors called if an object of class C was declared?
a) ~A() then ~B() then ~C()
b) ~C() then ~A() then ~B()
c) ~C() then ~B() then ~A()
d) ~B() then ~C() then ~A()
60. Instance of which type of class can’t be created?
a) Parent class
b) Abstract class
c) Anonymous class
d) Nested class
61. ___________ underlines the feature of Polymorphism in a class.
a) Virtual Function
b) Inline function
c) Enclosing class
d) Nested class
62. Which feature in OOP is used to allocate additional functions to a predefined operator in any
language?
a) Function Overloading
b) Function Overriding
c) Operator Overloading
d) Operator Overriding
63. Which feature can be implemented using encapsulation?
a) Polymorphism
b) Overloading
c) Inheritance
d) Abstraction
11
Based the following code answer question numbers from 64 to 70
1. package bookInfo;
2. public class Book {
3. private String title;
4. private String authName;
5. protected float price;
6. private static int num = 0;
7. public Book(String t, String n, float p){
8. title = t;
9. authName = n;
10. price = p;
11. num++;
12. }
13. public String getTitle(){
14. return title;
15. }
16. public void setTitle(String title){
17. this.title = title;
18. }
19. public String getAuthName(){
20. return authName;
21. }
22. public void setAuthName(String name){
23. this.authName = name;
24. }
25. public float getPrice(){
26. return price;
27. }
28. public void setPrice(float price){
29.
30. }
31. public static int getNum(){
32. return num;
33. }
34. }
35. class TestBook{
36. public static void main (String[] args) {
37.
]
38. }
39. }
64. Which of the following statement is correct when you insert at line 29?
A. = price; C. this.price = price;
B. price = this.price; D. None
65. Which of the following is a local variable in the above program?
A. title C. name
B. authName D. All
66. Which line of code is a package name in the above program?
A. Line 2 D. Line 32
B. Line 1 E. None
C. Line 3
12
67. Which of the following statement is correct to access variable num inside the main() method
of TestBook class?
A. TestBook.num; D. testbook.num;
B. Book.num; E. None
C. book.num;
68. Which of the following statement is correct to access title inside the main() method of
TestBook class using the object created: Book bk = new Book("computer",
"William Jems", 56)?
a) System.out.println(bk.title);
b) System.out.println(title);
c) System.out.println(bk.getTitle());
d) System.out.println(getTitle());
69. Which one is correct statement to call/invoke method getNum () inside the main() method?
A. Book.getNum(); D. getNum();
B. TestBook.getNum(); E. None
C. book.getNum();
70. Which of the following statement is false?
a) Book bk = new Object();
b) Object obj = new Book();
c) Object obj = new Object();
d) None
71. Which one of the following statement is true
a) A has-a relationship is implements via inheritance.
b) A House class has is-a relationship with door
c) On java it is possible subclass redefied a superclass method.
d) Superclass constructer is not inherited by sub class
e) all are correct
72. Inheritance means that __________
a) Data filed should be declared private.
b) A class can extends anther class
c) A variable of super type can refer to a subtype object
d) A class can contain anther class.
e) all are answer
73. Which of the following is false
a) “Class A extends B” means B is subset of A
b) A subclass is a subset of superclass
c) Subclass contain specific data filed and functionality in addition to the superclass
member.
d) Super class is define common behavior for related and unrelated classes.
13
e) Nane
74. Which error occur when a program doesn't perform the way it was intended to.
a) Logic errors
b) Syntax errors
c) Runtime errors
d) Runtime and Logic errors
e) None
14
b) Inheritance
c) Abstraction
d) Encapsulation
15
85. ____ is considered to be a partitioned area of computer memory that stores and set of
operations that can access the data.
a) Classes
b) Objects
c) Variables
d) Functions
89. ____ is the process of compartmentalizing the elements of an abstraction that contribute
to its structure and behavior?
a) Encapsulation
b) Abstraction
c) Classes
d) Inheritance
a) Static objects
b) Dynamic objects
c) a and b
16
a) Static objects
b) Dynamic objects
c) a and b
92. Which access specifier makes the class member accessible outside the class but can be
accessed by any subclass of that class?
a) Private
b) Public
c) Protected
a) Private
b) Public
c) Protected
94. When an object is created an initialization needs to be done which is automatically done
by the ____ function?
a) Constructor
b) Destructor
c) Friend
d) Member
a) Message parsing
b) Abstraction
c) Dynamic Binding
d) Encapsulation
96. The scope resolution operator is used to ____ function in the Inheritance.
a) Overload
b) Override
97. Which one is false about implicit and explicit casting object?
17
b) Student b = o; Implicit casting
c) Student b = (Student)o; Explicit casting
d) All are true
99. Which one is true to create using inner non-static class object
18