Midterm Lec Exam
Midterm Lec Exam
Question 1
Correct
a. class B + class A {}
Question 2
Correct
a. 3
b. 4
c. 2
d. 1
Question 3
Correct
d. Database, operations
Question 4
Correct
If static data members have to be used inside a class, those member functions
Question 5
Correct
What is the output of the below Java code with an abstract class and inner class? public abstract class AbstractClassTest6 { class
Anonymous { int a=5; } public static void main(String args[]) { System.out.print("Inner class is present.."); } }
b. No output
c. Compiler error
Question 6
Correct
Which among the following is wrong syntax related to static data members?
c. className :: staticDataMember;
Question 7
Correct
a. interface
b. Intf
c. intf
d. Interface
Question 8
Correct
b. An abstract class extending another abstract class, need not define methods of the super abstract class.
d. The first subclass of an abstract class should define all the abstract methods inherited from all the interfaces and super
abstract classes.
Question 9
Correct
Which of these can be used to fully abstract a class from its implementation?
a. Packages
b. Interfaces
d. Objects
Question 10
Correct
Which among the following is correct for the class defined below?
class student { int marks; public: student(){} student(int x) { marks=x; } }; main() { student s1(100); student s2(); student s3=100; return
0; }
Question 11
Correct
You read the following statement in a Java program that compiles and executes. submarine.dive(depth); What can you say for sure?
Question 12
Correct
c. Arrow operator
d. Dot operator
Question 13
Correct
Question 14
Correct
What is the output of the below Java program with an abstract class? abstract class MathLibrary { static final float PI = 3.1415f; } public
class AbstractClassTesting3 { public static void main(String[] args) { System.out.println(MathLibrary.PI); } }
a. Compiler error
c. No output
d. 3.1415
Question 15
Correct
Which among the following is the correct syntax to access static data member without using member function?
a. className . staticDataMember;
b. className : staticDataMember;
d. className :: staticDataMember;
Question 16
Correct
When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the
b. Subclass
d. Super class
Question 17
Correct
a. java.io
b. java.util
c. java.lang
d. java.system
Question 18
Correct
a. const
b. static
c. stat
d. common
Question 19
Correct
Question 20
Correct
a. No
b. Yes
Question 21
Correct
Question 22
Correct
a. Code efficiency
b. Code readability
c. Flexibility
d. Code reusability
Question 23
Correct
a. static member
b. private member
c. protected member
d. public member
Question 24
Correct
What is the output of the following code: class eq { public static void main(String args[]) { String s1 = “Hello”; String s2 = new
String(s1); System.out.println(s1==s2); } }
a. false
b. 1
c. 0
d. true
Question 25
Correct
Question 26
Correct
What is the correct way to implement an interface? Example, ‘Operation’ interface implements ‘Add’ class.
Question 27
Correct
a. Method declaration
b. Method name
c. Method definition
Question 28
Correct
a. private
b. Protected
c. Public
Question 29
Correct
a. Protected
b. Default
c. Private
d. Public
Question 30
Correct
Question 31
Correct
b. Private
c. Protected
d. Public
Question 32
Correct
In which access should a constructor be defined, so that object of the class can be created in any function?
a. Private
c. Public
d. Protected
Question 33
Correct
Question 34
Correct
Question 35
Correct
b. Abstract class defines only the structure of the class not its implementation
Question 36
Correct
If a class inheriting an abstract class does not define all of its function then it will be known as?
b. Abstract
c. Static class
d. A simple class
Question 37
Correct
Which of these keywords is used to prevent content of a variable from being modified?
a. static
b. last
c. final
d. constant
Question 38
Correct
a. TRUE
b. FALSE
Question 39
Correct
a. None
b. constructors
c. variables
d. methods
Question 40
Correct
a. run()
b. delete()
c. main()
d. finalize()
Question 41
Correct
Which constructor will be called from the object created in the below C++ code? class A { int i; A() { i=0; cout<<i; } A(int x=0) { i=x;
cout<<I; } }; A obj1;
c. Default constructor
d. Parameterized constructor
Question 42
Correct
a. Overloading ||
b. Overloading &&
c. Overloading +=
d. Overloading <<
Question 43
Correct
c. class A implements B C {}
Question 44
Correct
In object-oriented programming, the process by which one object acquires the properties of another object is called
a. Polymorphism
b. Inheritance
c. Overloading
d. Encapsulation
Question 45
Correct
a. Thread
b. List
d. AbstractList
Question 46
Correct
Question 47
Correct
Which of the following is the correct way of implementing an interface salary by class manager?
Question 48
Correct
d. Java is a fully object-oriented language with strong support for proper software engineering technique
Question 49
Correct
Question 50
Correct
d. It is feature of OOP