CS201 PreMidsem Merged
CS201 PreMidsem Merged
Courses /
Autumn 2021-22 /
BTech Sem-3 /
CS 201 /
Mid Semester Examination /
Pre-mid Semester Quiz Test
Question 1
Correct
Question 2
Correct
A programmer wants to make a member of a class visible only to all subclasses regardless of what package they are in. Which of the
following access specifiers can be used.
a. Private
b. Default
c. Protected
d. Public
Select one:
True
False
Question 4
Correct
int i;
}
class Main
{
System.out.println(t.i);
}
b. Garbage Value
c. Compiler Error
d. 0
{
public static void main(String args[])
{
boolean b = true;
System.out.println("CSE");
if (!b)
return;
System.out.println("ESC");
}
a. ESC
c. CSE
d. Compiler Error
Question 6
Correct
a. Yes
b. No
b.
The ability to tackle more challenging problems
d.
Improved communication between users, analysts, etc.
Question 8
Correct
class demo
{
int a, b;
demo()
{
a = 10;
b = 20;
}
class Test
{
obj1.a += 1;
obj1.b += 1;
System.out.println ("values of obj1 : ");
obj1.print();
System.out.println ("values of obj2 : ");
obj2.print();
}
a. Compiler Error
b.
values of obj1: a = 11 b = 21
values of obj2: a = 10 b = 20
values of obj2: a = 10 b = 21
values of obj2: a = 11 b = 21
values of obj2: a = 11 b = 21
Question 10
Incorrect
a. Analysis, design, and implementation steps in any order and going through the steps no more than one time.
b. Analysis, design, and implementation steps in the given order and going through the steps no more than one time.
c. Analysis, design, and implementation steps in any order and using multiple iterations
d. Analysis, design, and implementation steps in the given order and using multiple iterations.
Question 11
Incorrect
How many arguments are required in the definition of an overloaded unary operator?
a. 1
b. 3
c. 2
d. None
It is an error to have a method with the same signature in both the super class and its subclass
Select one:
True
False
Question 13
Correct
c.
Both the statements (a) and (b) are correct.
Question 14
Correct
A protected member of a superclass, when inherited into a subclass becomes which of the following types
a. Public
b. Default
c. Private
d. Protected
Question 15
Correct
Which of the following characteristics of an object-oriented programming language restricts behaviour so that an object can only
perform actions that are defined for its class?
a. Encapsulation
b. Polymorphism
c. Dynamic binding
d. Inheritance
Question 16
Correct
a. Classes
d. Attributes
b. Determines the amount of space needed for an object and creates the object.
Question 18
Incorrect
A normal method in a subclass must always invoke its super class constructor in its first statement
a. False
b. True
In multilevel inheritance, the last subclass inherits all methods and variables of
Question 20
Correct
A bookstore is working on an on-line ordering system. For each type of published material (books, movies, audio tapes) they need
to track the id, title, author(s), date published, and price. Which of the following would be the best design?
a. Create one class BookStore with the requested fields plus type.
c.
Create classes Book, Movie, and AudioTape with the requested fields.
d. Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
e. Create one class PublishedMaterial with the requested fields plus type.
Question 21
Incorrect
Question 22
Correct
Select one:
True
False
Question 23
Correct
Default (friendly) members of a super class are accessible to the subclass members, where both the classes are in different packages
Select one:
True
False
b. If you want to disallow instantiation of that class from outside that class
class one1
{
one1()
{
System.out.println("Hello");
}
}
class two2 extends one1
a. Compiler Error.
b. Blank. No output.
c. Hello Hello
d. Hello
Question 26
Correct
Answer: 4
boolean b = true;
System.out.println("CSE");
return;
System.out.println("ESC");
}
a. ESC
b. Compiler Error
c. CSE
Abstraction and encapsulation are fundamental principles that underlie the object-oriented approach to software development. What can
you say about the following two statements;
I. Abstraction allows us to focus on what something does without considering the complexities of how it works.
II. Encapsulation allows us to consider complex ideas while ignoring irrelevant details that would confuse us.
a. Only I is correct.
c.
Neither I nor II is correct.
d. Only II is correct.
Question 29
Incorrect
b. True
c. False
Operator overloading is
Question 31
Correct
b. Aggregation
c. Encapsulation
d. Inheritance
a. Execution time
b. Run time
c. Compile time
d. Coding time
Question 33
Correct
Protected members of a super class are accessible to the subclass members, where both the classes are in the same package.
Select one:
True
False
It is desired to design an object-oriented employee record system for a company. Each employee has a name, unique id and salary.
Employees belong to different categories and their salary is determined by their category. The functions to get Name, getld and
compute salary are required. Given the class hierarchy below, possible locations for these functions are;
Question 35
Correct
a. Same class
b. Everyone
c. Same Package
d. Subclass
Jump to...
Question 1
Correct
a. Each object of a class has its own copy of each non-static member variable.
b. All methods in a class are implicitly passed a 'this' parameter when called.
c. A static method can call other non-static methods in the same class by using the 'this' keyword.
e. A class may contain both static and non-static variables and both static and nonstatic methods.
Each object of a class has its own copy of each non-static member variable.
Question 2
Correct
a. 1, 2, and 4
b. 1, 3, and 4
c. 1, 2, 3, and 4
d. 2, 3, and 4
class Base {
}
}
System.out.println("Derived::show() called");
}
}
}
a. Derived::show() called
b. Compiler Error
c. Exception
d. Base::show() called
class A
{
public int i;
private int j;
}
class B extends A
{
void display()
{
super.j = super.i + 1;
System.out.println(super.i + " " + super.j);
}
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
a. 2 2
b. 3 3
c. Runtime Error
d. Compilation Error
A normal method in a subclass must always invoke its super class constructor in its first statement
a. True
b. False
Question 6
Incorrect
Class A is extending Class B. Which of the following keywords is used inside Class A to call the constructor of Class A.
a. super
b. static
c. this
d. final
Question 7
Correct
Which of the following characteristics of an object-oriented programming language restricts behaviour so that an object can only
perform actions that are defined for its class?
a. Dynamic binding
b. Polymorphism
c. Inheritance
d. Encapsulation
a. Abstract class cannot have constructors but can not have static methods
b. True
c. Abstract class can have constructors but can not have static methods
d. False
Question 9
Incorrect
class B
{
int b;
public B(int b)
{
b = b;
}
}
}
a. 0, 10
b. 0
c. 10
d. 20
a. Multilevel Inheritance
b. Multiple Inheritance
Question 11
Incorrect
Abstraction and encapsulation are fundamental principles that underlie the object-oriented approach to software development. What can
you say about the following two statements;
I. Abstraction allows us to focus on what something does without considering the complexities of how it works.
II. Encapsulation allows us to consider complex ideas while ignoring irrelevant details that would confuse us.
a. Only II is correct.
b.
Neither I nor II is correct.
c. Only I is correct.
Question 12
Correct
A programmer wants to make a member of a class visible only to all subclasses regardless of what package they are in. Which of the
following access specifiers can be used.
a. Protected
b. Default
c. Private
d. Public
Question 13
Correct
b. Aggregation
c. Inheritance
d. Encapsulation
System.out.println();
}
public Bowling () {
System.out.println();
}
static {
System.out.println();
}
{
System.out.println();
}
}
a. Two
b. One
c. None
d. Three
class check {
int x = 20;
System.out.println(x);
}
static
{
int x = 10;
System.out.print(x + " ");
}
}
a. 20 10
b. 10 20
c. 20 20
d. 10 10
Question 16
Correct
b.
Determines the amount of space needed for an object and creates the object.
class Main {
public static void main(String args[]){
final int i;
i = 20;
System.out.println(i);
}
}
a. 0
b. Garbage value
c. Compilation Error
d. 20
Question 18
Correct
Class A is extending Class B. Which of the following keyword is used inside Class A to call the constructor of Class B
a. static
b. this
c. super
d. final
class A
{
{
A x = new A();
a. 1
b. 2
c. 3
d. 0
Question 20
Incorrect
b. False
c. True
a. Import
b. Export
c. Extends
d. Package
Question 22
Correct
Select one:
True
False
public int a;
demo()
a = 10;
}
{
this.a = a;
{
Test obj = new Test();
obj.set(20);
obj.get();
}
}
a. a = 10
b. Compilation Error
c. NULL
d. a = 20
}
}
}
class check {
TestRunner.succeeded = 99;
tr.display();
}
a. 0 0
b. 1 99
c. 99 99
d. 99 0
Select one:
True
False
Question 26
Correct
Question 27
Correct
b.
A class can be made abstract without any abstract method
c. If we derive an abstract class and do not implement all the abstract methods, then the derived class should also be marked as
abstract using 'abstract' keyword
Question 28
Correct
Given that Student is a class, how many reference variables and objects are created by the following code?
Question 29
Correct
a. Constructors
Question 30
Correct
A protected member of a superclass, when inherited into a subclass becomes which of the following types
a. Protected
b. Default
c. Public
d. Private
What should be the execution order, if a class has a method, static block, instance block, and constructor, as shown below?
public class First_C {
System.out.println("Method");
}
{
}
System.out.println("Constructor ");
}
static {
System.out.println("static block");
}
c.First_C();
c.myMethod();
}
}
a.
Instance block, method, static block, and constructor
Default (friendly) members of a super class are accessible to the subclass members, where both the classes are in different packages
Select one:
True
False
Question 33
Correct
d.
Reusability of analysis, design, and programming results
Question 34
Correct
Select one:
True
False
a. No
b. Yes
Jump to...
/
OFFLINE STUDENTS Pre-End Semester Examination
Question 1
Incorrect
class Test
{
int i;
}
class Main
{
public static void main(String args[]) {
Test t;
System.out.println(t.i);
b. Garbage Value
c. Compiler Error
d. 0
Question 2
Correct
When the same method call may at different times invoke different methods based on the dynamic type, this is called
Answer: POLYMORPHISM
Question 3
Correct
It is an error to have a method with the same signature in both the super class and its subclass
Select one:
True
False
Question 4
Correct
Answer: STATIC
Question 5
Correct
In an Interface
Question 6
Correct
In multilevel inheritance, the last subclass inherits all methods and variables of
Question 7
Correct
Select one:
True
False
Question 8
Correct
Question 9
Correct
Select one:
True
False
Question 10
Correct
The programmer must explicitly create the System.in and System.out objects.
Select one:
True
False
Question 11
Correct
Select the method that should be overridden to provide thread's behaviour when Thread class is extended
a. yield
b. start
c. notify
d. run
Question 12
Correct
Question 13
Correct
c. If you want to disallow instantiation of that class from outside that class
Question 14
Incorrect
a. 1, 2, and 4
b. 2, 3, and 4
c. 1, 2, 3, and 4
d. 1, 3, and 4
1, 3, and 4
Question 15
Incorrect
}
}
}
class check {
TestRunner.succeeded = 99;
tr.display();
}
a. 1 99
b. 99 0
c. 0 0
d. 99 99
Question 16
Incorrect
class A
{
public int i;
private int j;
}
class B extends A
{
void display()
{
super.j = super.i + 1;
System.out.println(super.i + " " + super.j);
}
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
a. 2 2
b. 3 3
c. Compilation Error
d. Runtime Error
Question 17
Incorrect
public int a;
demo()
a = 10;
}
{
this.a = a;
{
Test obj = new Test();
obj.set(20);
obj.get();
}
}
a. a = 10
b. NULL
c. Compilation Error
d. a = 20
Question 18
Incorrect
Select one:
True
False
Question 19
Incorrect
Select one:
True
False
Question 20
Correct
Select one:
True
False
Question 21
Correct
System.out.println();
}
public Bowling () {
System.out.println();
}
static {
System.out.println();
}
{
System.out.println();
}
}
a. Three
b. None
c. One
d. Two
Question 22
Correct
It is desired to design an object-oriented employee record system for a company. Each employee has a name, unique id and salary.
Employees belong to different categories and their salary is determined by their category. The functions to get Name, getld and
compute salary are required. Given the class hierarchy below, possible locations for these functions are;
Question 23
Correct
Choose the correct line of code which should be used to start the Thread
Question 24
Incorrect
A bookstore is working on an on-line ordering system. For each type of published material (books, movies, audio tapes) they need
to track the id, title, author(s), date published, and price. Which of the following would be the best design?
b. Create classes Book, Movie, and AudioTape with the requested fields.
c. Create one class BookStore with the requested fields plus type.
d. Create one class PublishedMaterial with the requested fields plus type.
e. Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
Question 25
Correct
{
int b;
b = b;
}
{
B x = new B(10);
System.out.println("x.b :"+x.b);
}
a. 0
b. 0, 10
c. 10
d. 20
Question 26
Incorrect
class check {
int x = 20;
System.out.println(x);
}
static
{
int x = 10;
System.out.print(x + " ");
}
}
a. 20 20
b. 10 20
c. 20 10
d. 10 10
Question 27
Correct
a. Multiple Inheritance
b. Multilevel Inheritance
Question 28
Correct
b.
classname objectname= new classname();
Question 29
Incorrect
What should be the execution order, if a class has a method, static block, instance block, and constructor, as shown below?
public class First_C {
System.out.println("Method");
}
{
}
System.out.println("Constructor ");
}
static {
System.out.println("static block");
}
c.First_C();
c.myMethod();
}
}
Question 30
Correct
c. Determines the amount of space needed for an object and creates the object.
Question 31
Correct
Question 32
Correct
a. A situation where a thread is waiting to acquire an object lock that another thread holds, and this second thread is waiting for an
object lock that the first thread holds.
b. A situation where a low priority thread waiting to acquire an I/O resource but other high priority threads never relinquish the
resources.
d. A situation where two threads are executing concurrently and requesting for separate resources.
Question 33
Incorrect
a. java.lang.String
b. java.lang.Runnable
c. java.lang.Object
d. java.lang.Thread
Question 34
Incorrect
a. an 'is-a' relationship
b. both
c. a 'has-a' relationship
d. Niether
Question 35
Incorrect
A subclass can --------------- a superclass method by declaring a method with the same signature as the superclass method.
Answer: ACCESS
Question 36
Incorrect
a. Hi
hello
world
b. hello
world
c. Hi hello
Hi world
d. Hi
Hi
Hi
Question 37
Incorrect
Answer: SUPER
Question 38
Correct
Protected members of a super class are accessible to the subclass members, where both the classes are in the same package.
Select one:
True
False
Question 39
Incorrect
class one1
{
one1()
{
System.out.println("Hello");
}
}
class two2 extends one1
a. Hello Hello
b. Blank. No output.
c. Compiler Error.
d. Hello
Question 40
Incorrect
Abstraction and encapsulation are fundamental principles that underlie the object-oriented approach to software development. What can
you say about the following two statements;
I. Abstraction allows us to focus on what something does without considering the complexities of how it works.
II. Encapsulation allows us to consider complex ideas while ignoring irrelevant details that would confuse us.
a.
Neither I nor II is correct.
b. Only I is correct.
c. Only II is correct.
Question 41
Correct
a. Multiple
c. 1
Question 42
Correct
How many arguments are required in the definition of an overloaded unary operator?
a. None
b. 2
c. 3
d. 1
Question 43
Incorrect
Answer: DATA
Question 44
Correct
Operator overloading is
Question 45
Correct
Given that Student is a class, how many reference variables and objects are created by the following code?
Student studentName, studentId;
Question 46
Correct
An individual array element that is passed to a method and modified in that method will contain the modified value when the called method
completes execution
Select one:
True
False
Question 47
Correct
Question 48
Incorrect
a. 1, 2, and 4
b. 1, 2, 3, and 4
c. 1, 3, and 4
d. 2, 3, and 4
Question 49
Correct
a. start()
b. runnable()
c. init()
d. run()
Question 50
Incorrect
{
public int a;
demo()
{
a = 10;
}
this.a = a;
}
{
System.out.println("a = " + a);
obj.get();
}
a. a=10
b. a=10; a=20;
c. Compilation Error
d. a=20
Question 52
Correct
Answer: EXTENDS
Question 53
Correct
It is an error if a class with one or more abstract methods is not explicitly declared as abstract.
Select one:
True
False
Question 54
Incorrect
d.
If we derive an abstract class and do not implement all the abstract methods, then the derived class should also be marked as
abstract using ‘abstract’ keyword
Question 55
Correct
b.
The ability to tackle more challenging problems
d.
Improved communication between users, analysts, etc.
Jump to...
ONLINE STUDENTS Pre-End Semester Examination ►