CS 201 End Sem
CS 201 End Sem
Question 1
Correct
a. run()
b. runnable()
c. start()
d. init()
Question 2
Incorrect
Question 3
Correct
{
public int a;
demo()
{
a = 10;
this.a = a;
}
{
System.out.println("a = " + a);
obj.get();
}
a. a=10; a=20;
b. a=10
c. a=20
d. Compilation Error
Question 4
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. final
d. super
Question 5
Correct
The programmer must explicitly create the System.in and System.out objects.
Select one:
True
False
Question 6
Incorrect
When the same method call may at different times invoke different methods based on the dynamic type, this is called
Answer: Overloading
Question 7
Correct
A protected member of a superclass, when inherited into a subclass becomes which of the following types
a. Default
b. Public
c. Private
d. Protected
Question 8
Correct
Question 9
Incorrect
a. False
b. Abstract class cannot have constructors but can not have static methods
c. True
d. Abstract class can have constructors but can not have static methods
Question 10
Correct
a. Encapsulation
b. Aggregation
c. Inheritance
Question 11
Correct
Answer: final
Question 12
Incorrect
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 13
Correct
Answer: extends
Question 14
Correct
Select one:
True
False
Question 15
Correct
a. Determines the amount of space needed for an object and creates the object.
Question 16
Correct
Question 17
Correct
Select the method that should be overridden to provide thread's behaviour when Thread class is extended
a. yield
b. run
c. notify
d. start
Question 18
Incorrect
a. an 'is-a' relationship
b. a 'has-a' relationship
c. Niether
d. both
Question 19
Incorrect
Question 20
Incorrect
a. java.lang.Object
b. java.lang.Runnable
c. java.lang.String
d. java.lang.Thread
Question 21
Correct
How many arguments are required in the definition of an overloaded unary operator?
a. None
b. 3
c. 1
d. 2
Question 22
Correct
a. No
b. Yes
Question 23
Correct
b.
A class can be made abstract without any abstract method
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 24
Incorrect
Select one:
True
False
Question 25
Incorrect
In an Interface
Question 26
Incorrect
In multilevel inheritance, the last subclass inherits all methods and variables of
Question 27
Correct
Question 28
Correct
a. hello
world
b. Hi
hello
world
c. Hi
Hi
d. Hi hello
Hi world
Question 29
Incorrect
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 30
Incorrect
a. True
c. False
Question 31
Correct
a. 1, 3, and 4
b. 1, 2, and 4
c. 2, 3, and 4
d. 1, 2, 3, and 4
1, 3, and 4
Question 32
Incorrect
Question 33
Correct
A subclass can --------------- a superclass method by declaring a method with the same signature as the superclass method.
Answer: override
Question 34
Correct
Answer: super
Question 35
Correct
a. No
b. Yes
Question 36
Correct
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 37
Incorrect
class check {
{
int x = 20;
System.out.println(x);
}
static
{
int x = 10;
System.out.print(x + " ");
a. 20 20
b. 20 10
c. 10 10
d. 10 20
Question 38
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 39
Incorrect
d. If you want to disallow instantiation of that class from outside that class
Question 40
Correct
Question 41
Incorrect
{
int b;
b = b;
}
public static void main (String[] args)
{
B x = new B(10);
System.out.println("x.b :"+x.b);
}
a. 10
b. 0, 10
c. 0
d. 20
Question 42
Correct
a. A situation where two threads are executing concurrently and requesting for separate resources.
b. 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.
c. A situation where a low priority thread waiting to acquire an I/O resource but other high priority threads never relinquish the
resources.
Question 43
Correct
Select one:
True
False
Question 44
Correct
b. Attributes
d. Classes
Question 45
Correct
b. Multiple
d. 1
Question 46
Correct
a. A class may contain both static and non-static variables and both static and nonstatic methods.
b. Each object of a class has its own copy of each non-static member variable.
c. All methods in a class are implicitly passed a 'this' parameter when called.
e. A static method can call other non-static methods in the same class by using the 'this' keyword.
Each object of a class has its own copy of each non-static member variable.
Question 47
Correct
Answer: static
Question 48
Correct
Operator overloading is
Question 49
Incorrect
a. Multiple Inheritance
b. Multilevel Inheritance
Question 50
Correct
class Main {
public static void main(String args[]){
final int i;
i = 20;
System.out.println(i);
}
}
a. 0
b. Garbage value
c. 20
d. Compilation Error
Question 51
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. this
b. static
c. final
d. super
Question 52
Incorrect
}
}
}
}
b.show();
}
a. Base::show() called
b. Exception
c. Compiler Error
d. Derived::show() called
Question 53
Correct
Choose the correct line of code which should be used to start the Thread
Question 54
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 the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
b. Create one class BookStore with the requested fields plus type.
c. Create classes Book, Movie, and AudioTape with the requested fields.
e. Create one class PublishedMaterial with the requested fields plus type.
Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
Question 55
Correct
Select one:
True
False
Jump to...
Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Mid Semester Examination / Mid Semester Online Examination
Question 1
Correct
class A
{
{
A x = new A();
a. 1
b. 2
c. 3
d. 0
Correct
a. Package
b. Extends
c. Export
d. Import
Question 3
Correct
a. Abstract class cannot have constructors but can not have static methods
b. False
c. True
d. Abstract class can have constructors but can not have static methods
Question 4
Correct
Select one:
True
False
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?
b. Create one class BookStore with the requested fields plus type.
c. Create classes Book, Movie, and AudioTape with the requested fields.
d. Create one class PublishedMaterial with the requested fields plus type.
e.
Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
Question 6
Incorrect
b.
A class can be made abstract without any abstract method
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
Incorrect
c. False
d. True
Question 8
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. Dynamic binding
c. Inheritance
d. Polymorphism
Correct
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(" Instance Block");
}
System.out.println("Constructor ");
}
static {
System.out.println("static block");
}
c.First_C();
c.myMethod();
}
}
a.
Instance block, method, static block, and constructor
Correct
b. Constructors
Question 11
Correct
Select one:
True
False
Question 12
Correct
a. Same Package
b. Subclass
c. Same class
d. Everyone
Incorrect
}
}
}
}
b.show();
}
a. Exception
b. Compiler Error
c. Derived::show() called
d. Base::show() called
Correct
a. Multiple Inheritance
b. Multilevel Inheritance
Correct
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. Runtime Error
b. 3 3
c. 2 2
d. Compilation Error
Correct
a. 1, 2, 3, and 4
b. 2, 3, and 4
c. 1, 3, and 4
d. 1, 2, and 4
Question 17
Correct
How many arguments are required in the definition of an overloaded unary operator?
a. 2
b. 3
c. None
d. 1
Correct
a. A class may contain both static and non-static variables and both static and nonstatic methods.
b. Each object of a class has its own copy of each non-static member variable.
d. All methods in a class are implicitly passed a 'this' parameter when called.
e. A static method can call other non-static methods in the same class by using the 'this' keyword.
Each object of a class has its own copy of each non-static member variable.
Question 19
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
Incorrect
In multilevel inheritance, the last subclass inherits all methods and variables of
Incorrect
{
System.out.println();
}
public Bowling () {
System.out.println();
}
static {
System.out.println();
}
{
System.out.println();
}
}
a. Two
b. One
c. None
d. Three
Correct
Select one:
True
False
Question 23
Correct
Given that Student is a class, how many reference variables and objects are created by the following code?
Correct
public TestRunner() {
}
}
class check {
tr.display();
}
a. 99 99
b. 1 99
c. 0 0
d. 99 0
Incorrect
Question 26
Correct
class Main {
public static void main(String args[]){
final int i;
i = 20;
System.out.println(i);
}
a. Compilation Error
b. 0
c. Garbage value
d. 20
Correct
a. No
b. Yes
Question 28
Correct
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
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;
i. getld is implemented in the superclass
Correct
Incorrect
{
int b;
b = b;
}
public static void main (String[] args)
{
B x = new B(10);
System.out.println("x.b :"+x.b);
}
a. 0
b. 20
c. 10
d. 0, 10
Incorrect
a. Yes
b. No
Question 33
Incorrect
boolean b = true;
System.out.println("CSE");
return;
System.out.println("ESC");
}
}
a. CSE
b. ESC
d. Compiler Error
Not answered
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. final
d. this
Not answered
public int a;
demo()
{
a = 10;
}
{
this.a = a;
{
Test obj = new Test();
obj.set(20);
obj.get();
}
}
a. a = 10
b. a = 20
c. Compilation Error
d. NULL
The correct answer is:
Compilation Error
Jump to...
Question 1
Correct
a. Run time
b. Coding time
c. Execution time
d. Compile time
Question 2
Correct
Question 3
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 the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
b. Create one class BookStore with the requested fields plus type.
c. Create classes Book, Movie, and AudioTape with the requested fields.
e. Create one class PublishedMaterial with the requested fields plus type.
Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.
Question 4
Correct
a. Everyone
b. Same class
c. Subclass
d. Same Package
Question 5
Incorrect
{
int i;
}
class Main
System.out.println(t.i);
}
a. 0
b. Compiler Error
d. Garbage Value
Question 6
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;
i. getld is implemented in the superclass
Question 7
Correct
Question 8
Correct
Select one:
True
False
Question 9
Correct
a. Determines the amount of space needed for an object and creates the object.
Question 10
Correct
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 II is correct.
c. Only I is correct.
Question 11
Correct
a. Encapsulation
b. Aggregation
c. Inheritance
Question 12
Correct
Operator overloading is
Question 13
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. Polymorphism
b. Encapsulation
c. Dynamic binding
d. Inheritance
Question 14
Incorrect
a. True
b. False
Question 15
Correct
{
public static void main(String args[])
{
boolean b = true;
System.out.println("CSE");
if (!b)
return;
System.out.println("ESC");
}
b. CSE
c. Compiler Error
d. ESC
Question 16
Incorrect
a. No
b. Yes
Question 17
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. Public
b. Protected
c. Private
d. Default
Question 18
Correct
Select one:
True
False
Question 19
Correct
class demo
{
int a, b;
demo()
{
a = 10;
b = 20;
}
}
}
class Test
{
{
demo obj1 = new demo();
obj1.a += 1;
obj1.b += 1;
System.out.println ("values of obj1 : ");
obj1.print();
}
values of obj2: a = 10 b = 21
b. Compiler Error
values of obj2: a = 11 b = 21
values of obj2: a = 10 b = 20
values of obj2: a = 11 b = 21
Question 20
Correct
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 any order and using multiple iterations
c. Analysis, design, and implementation steps in the given order and using multiple iterations.
d. Analysis, design, and implementation steps in the given order and going through the steps no more than one time.
Question 21
Correct
A protected member of a superclass, when inherited into a subclass becomes which of the following types
a. Public
b. Private
c. Default
d. Protected
Question 22
Correct
Answer: 4
Question 23
Incorrect
Question 24
Correct
Question 25
Incorrect
c. Classes
d. Attributes
Question 26
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
Question 27
Incorrect
How many arguments are required in the definition of an overloaded unary operator?
a. 2
b. 3
c. None
d. 1
Question 28
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 29
Incorrect
In multilevel inheritance, the last subclass inherits all methods and variables of
Question 30
Correct
c.
Reusability of analysis, design, and programming results
Question 31
Incorrect
A normal method in a subclass must always invoke its super class constructor in its first statement
a. False
b. True
Question 32
Incorrect
boolean b = true;
System.out.println("CSE");
return;
System.out.println("ESC");
}
b. CSE
c. ESC
d. Compiler Error
Question 33
Incorrect
class one1
{
one1()
{
System.out.println("Hello");
}
{
two2 t = new two2();
a. Hello
b. Compiler Error.
c. Hello Hello
d. Blank. No output.
Question 34
Incorrect
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 35
Incorrect
b. If you want to disallow instantiation of that class from outside that class
◄ Weekly Quiz 2
Jump to...
Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Continuous Evaluation / Weekly Quiz 2
Question 1
Correct
{
System.out.println("Integer");
}
void display(double x)
System.out.println("Double");
}
}
}
a. Double
b. Error in compilation
d. Integer
Question 2
Correct
b. Multiple
c. None
d. 1
Question 3
Incorrect
The correct answer is: Expresses a part-of relationship and is a stronger form of an association relationship.
Question 4
Correct
The fact that the same operation may apply to two or more classes is called what?
b. Multiple Classification
c. Encapsulation
d. Polymorphism
Question 5
Correct
a. Scope
b. Update
c. Query
d. Constructor
Question 6
Incorrect
class test
{
void display(int x)
{
System.out.println(“CSE”);
}
int display(int x)
{
return 5;
}
}
a. 1
b. 2
c. 3
d. 0
◄ Weekly Quiz 1
Jump to...
Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Continuous Evaluation / Weekly Quiz 1
Question 1
Correct
Question 2
Correct
The feature in object-oriented programming that allows the same operation to be carried out differently, depending on the object, is:
a. Polymorphism
b. Inheritance
c. Overriding
d. Overfunctioning
Correct
a. 127
c. 32768
d. 1
Question 4
Incorrect
a. Parent of an object
b. Instance of an object
c. Blueprint of an object
d. Scope of an object
Question 5
Correct
In a class, member variables are often called its _________, and its member functions are sometimes referred to as its behaviour, or
____________.
a. values, morals
b. attributes, methods
c. data, activities
d. attributes, activities
Question 6
Incorrect
Which of the following concepts of OOPS means exposing only necessary information to clients?
a. Data Binding
b. Abstraction
c. Encapsulation
d. Data Hiding
◄ Announcements
Jump to...
Weekly Quiz 2 ►