0% found this document useful (0 votes)
71 views18 pages

Midterm Lec Exam

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)
71 views18 pages

Midterm Lec Exam

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
You are on page 1/ 18

Home / My courses / UGRD-CS6203-2313T / MIDTERM EXAM / MIDTERM EXAM

Started on Thursday, 16 November 2023, 8:58 AM


State Finished
Completed on Thursday, 16 November 2023, 10:17 AM
Time taken 1 hour 19 mins
Marks 50.00/50.00
Grade 100.00 out of 100.00

Question 1
Correct

Mark 1.00 out of 1.00

Which of these is correct way of inheriting class A by class B?

a. class B + class A {}

b. class B extends class A {}

c. class B extends A {}

d. class B inherits class A {}

Your answer is correct.

Question 2
Correct

Mark 1.00 out of 1.00

How many types of access specifiers are provided in OOP (C++)?

a. 3

b. 4

c. 2

d. 1

Your answer is correct.


Question 3

Correct

Mark 1.00 out of 1.00

An abstract data typically comprises a …………… and a set of ……………... respectively.

a. Data representation, operations

b. Data representation, classes

c. Data representation, objects

d. Database, operations

Your answer is correct.

Question 4
Correct

Mark 1.00 out of 1.00

If static data members have to be used inside a class, those member functions

a. Must not be member functions

b. Must be static member functions

c. Must not be static member functions

d. Must not be member function of corresponding class

Your answer is correct.

Question 5
Correct

Mark 1.00 out of 1.00

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.."); } }

a. Inner class is present..

b. No output

c. Compiler error

d. None of the above

Your answer is correct.


Question 6

Correct

Mark 1.00 out of 1.00

Which among the following is wrong syntax related to static data members?

a. static dataType memberName;

b. dataType className :: memberName =value;

c. className :: staticDataMember;

d. className : dataType -> memberName;

Your answer is correct.

Question 7
Correct

Mark 1.00 out of 1.00

Which of these keywords is used to define interfaces in Java?

a. interface

b. Intf

c. intf

d. Interface

Your answer is correct.

Question 8
Correct

Mark 1.00 out of 1.00

Choose correct statements about an Abstract class in Java?

a. An abstract class implementing an Interface, need not implement methods of an interface

b. An abstract class extending another abstract class, need not define methods of the super abstract class.

c. All the above

d. The first subclass of an abstract class should define all the abstract methods inherited from all the interfaces and super
abstract classes.

Your answer is correct.


Question 9

Correct

Mark 1.00 out of 1.00

Which of these can be used to fully abstract a class from its implementation?

a. Packages

b. Interfaces

c. None of the Mentioned

d. Objects

Your answer is correct.

Question 10
Correct

Mark 1.00 out of 1.00

Which among the following is correct for the class defined below?

a. Program runs and all objects are create

b. Program will give compile time error

c. Only object s1 and s2 will be created

d. Object s3, syntax error

Your answer is correct.

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

Mark 1.00 out of 1.00

You read the following statement in a Java program that compiles and executes. submarine.dive(depth); What can you say for sure?

a. submarine must be the name of a class

b. dive must be the name of an instance field.

c. dive must be a method.

d. depth must be an int

Your answer is correct.


Question 12

Correct

Mark 1.00 out of 1.00

How to access data members of a class?

a. Dot or arrow as required

b. Dot, arrow or direct call

c. Arrow operator

d. Dot operator

Your answer is correct.

Question 13
Correct

Mark 1.00 out of 1.00

A protected member can be accessed in,

a. a non-subclass of the same package

b. a subclass of the same package

c. a subclass of different package

d. a non-subclass of different package

Your answer is correct.

Question 14
Correct

Mark 1.00 out of 1.00

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

b. None of the above

c. No output

d. 3.1415

Your answer is correct.


Question 15

Correct

Mark 1.00 out of 1.00

Which among the following is the correct syntax to access static data member without using member function?

a. className . staticDataMember;

b. className : staticDataMember;

c. className -> staticDataMember;

d. className :: staticDataMember;

Your answer is correct.

Question 16
Correct

Mark 1.00 out of 1.00

When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the

a. Compiler will choose randomly

b. Subclass

c. Interpreter will choose randomly

d. Super class

Your answer is correct.

Question 17
Correct

Mark 1.00 out of 1.00

Which of these packages contains abstract keyword?

a. java.io

b. java.util

c. java.lang

d. java.system

Your answer is correct.


Question 18

Correct

Mark 1.00 out of 1.00

Which keyword should be used to declare static variables?

a. const

b. static

c. stat

d. common

Your answer is correct.

Question 19
Correct

Mark 1.00 out of 1.00

The copy constructors can be used to ________

a. Copy an object so that it can be passed to another primitive type variable

b. Copy an object so that it can be passed to a class

c. Copy an object so that it can be passed to a function

d. Copy an object for type casting

Your answer is correct.

Question 20
Correct

Mark 1.00 out of 1.00

Can we declare an interface as final?

a. No

b. Yes

Your answer is correct.


Question 21

Correct

Mark 1.00 out of 1.00

What happens when an object is passed by reference?

a. Destructor is not called

b. Destructor is called when function is out of scope

c. Destructor is called when called explicitly

d. Destructor is called at end of function

Your answer is correct.

Question 22
Correct

Mark 1.00 out of 1.00

In multilevel inheritance, which is the most significant feature of OOP used?

a. Code efficiency

b. Code readability

c. Flexibility

d. Code reusability

Your answer is correct.

Question 23
Correct

Mark 1.00 out of 1.00

A class member declared protected becomes a member of a subclass of which type?

a. static member

b. private member

c. protected member

d. public member

Your answer is correct.


Question 24

Correct

Mark 1.00 out of 1.00

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

Your answer is correct.

Question 25
Correct

Mark 1.00 out of 1.00

The correct order of the declarations in a Java program is-

a. Import statement, class declaration, package declaration

b. Import statement, package declaration, class declaration

c. Package declaration, import statement, class declaration

d. Class declaration, import statement, package declaration

Your answer is correct.

Question 26
Correct

Mark 1.00 out of 1.00

What is the correct way to implement an interface? Example, ‘Operation’ interface implements ‘Add’ class.

a. class Add extends Operation{}

b. None of the above

c. class Add implements Operation{}

d. class Add import Operation{}

Your answer is correct.


Question 27

Correct

Mark 1.00 out of 1.00

What does an interface contain?

a. Method declaration

b. Method name

c. Method definition

d. Declaration and definition of the method

Your answer is correct.

Question 28
Correct

Mark 1.00 out of 1.00

Which of these access specifiers can be used for an interface?

a. private

b. Protected

c. Public

d. All of the mentioned

Your answer is correct.

Question 29
Correct

Mark 1.00 out of 1.00

Which access specifier is usually used for data members of a class?

a. Protected

b. Default

c. Private

d. Public

Your answer is correct.


Question 30

Correct

Mark 1.00 out of 1.00

Which is the correct syntax for declaring static data member?

a. dataType static memberName;

b. static memberName dataType;

c. static dataType memberName;

d. memberName static dataType;

Your answer is correct.

Question 31
Correct

Mark 1.00 out of 1.00

Which type of members can’t be accessed in derived classes of a base class?

a. All can be accessed

b. Private

c. Protected

d. Public

Your answer is correct.

Question 32
Correct

Mark 1.00 out of 1.00

In which access should a constructor be defined, so that object of the class can be created in any function?

a. Private

b. Any access specifier will work

c. Public

d. Protected

Your answer is correct.


Question 33

Correct

Mark 1.00 out of 1.00

Which is the correct syntax of inheritance?

a. class derived_classname : base_classname{ /*define class body*/ };

b. class derived_classname : access base_classname{ /*define class body*/ };

c. class base_classname :access derived_classname{ /*define class body*/ };

d. class base_classname : derived_classname{ /*define class body*/ };

Your answer is correct.

Question 34
Correct

Mark 1.00 out of 1.00

What is an abstraction in object-oriented programming?

a. Hiding the implementation

b. Hiding the implementation and showing only the features

c. Showing the important data

d. Hiding the important data

Your answer is correct.

Question 35
Correct

Mark 1.00 out of 1.00

Which of these is not a correct statement?

a. Abstract class can be inherited

b. Abstract class defines only the structure of the class not its implementation

c. Abstract class can be initiated by new operator

d. Every class containing abstract method must be declared abstract

Your answer is correct.


Question 36

Correct

Mark 1.00 out of 1.00

If a class inheriting an abstract class does not define all of its function then it will be known as?

a. None of the mentioned

b. Abstract

c. Static class

d. A simple class

Your answer is correct.

Question 37
Correct

Mark 1.00 out of 1.00

Which of these keywords is used to prevent content of a variable from being modified?

a. static

b. last

c. final

d. constant

Your answer is correct.

Question 38
Correct

Mark 1.00 out of 1.00

The class whose properties are inherited is known as superclass.

a. TRUE

b. FALSE

c. Can not say

d. Can be true or false

Your answer is correct.


Question 39

Correct

Mark 1.00 out of 1.00

An abstract class in Java usually contains one or more abstract ____.

a. None

b. constructors

c. variables

d. methods

Your answer is correct.

Question 40
Correct

Mark 1.00 out of 1.00

Which of these methods must be made static?

a. run()

b. delete()

c. main()

d. finalize()

Your answer is correct.

Question 41
Correct

Mark 1.00 out of 1.00

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;

a. Run time error

b. Compile time error

c. Default constructor

d. Parameterized constructor

Your answer is correct.


Question 42

Correct

Mark 1.00 out of 1.00

Which among the following can show polymorphism?

a. Overloading ||

b. Overloading &&

c. Overloading +=

d. Overloading <<

Your answer is correct.

Question 43
Correct

Mark 1.00 out of 1.00

Which is the correct declaration to implement two interfaces?

a. class A implements B, implements C {}

b. None of the above

c. class A implements B C {}

d. class A implements B, C {}

Your answer is correct.

Question 44
Correct

Mark 1.00 out of 1.00

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

Your answer is correct.


Question 45

Correct

Mark 1.00 out of 1.00

Which of these is not abstract?

a. Thread

b. List

c. None of the Mentioned

d. AbstractList

Your answer is correct.

Question 46
Correct

Mark 1.00 out of 1.00

Choose a correct statement about abstract classes?

a. All the above.

b. An abstract class can extend a concrete class

c. An abstract class can extend another abstract class

d. An abstract class can implement any number of interfaces

Your answer is correct.

Question 47
Correct

Mark 1.00 out of 1.00

Which of the following is the correct way of implementing an interface salary by class manager?

a. class manager implements salary {}

b. class manager extends salary {}

c. none of the mentioned

d. class manager imports salary {}

Your answer is correct.


Question 48

Correct

Mark 1.00 out of 1.00

Mark the incorrect statement from the following:

a. In java it is not easy to write C-like so called procedural programs

b. In java language objects have to be manipulated

c. In java language error processing is built into the language

d. Java is a fully object-oriented language with strong support for proper software engineering technique

Your answer is correct.

Question 49
Correct

Mark 1.00 out of 1.00

Which among the following, for a pure OOP language, is true?

a. The language must follow only 3 features of OOP

b. The language should follow 3 or more features of OOP

c. The language should follow at least 1 feature of OOP

d. The language must follow all the rules of OOP

Your answer is correct.

Question 50
Correct

Mark 1.00 out of 1.00

Which of the following is not true about polymorphism?

a. Ease in readability of program

b. Increases overhead of function definition always

c. Helps in redefining the same functionality

d. It is feature of OOP

Your answer is correct.

◄ Prelim Lab Exam 


Jump to...

Midterm Lab Exam ►

You might also like