0% found this document useful (0 votes)
44 views81 pages

CS 201 End Sem

new notes

Uploaded by

Rakesh Kumar
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)
44 views81 pages

CS 201 End Sem

new notes

Uploaded by

Rakesh Kumar
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/ 81

Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Pre-End Semester Examination

/ ONLINE STUDENTS Pre-End Semester Examination

Started on Wednesday, 8 December 2021, 2:03 PM


State Finished
Completed on Wednesday, 8 December 2021, 3:03 PM
Time taken 1 hour
Marks 36.00/55.00
Grade 9.82 out of 15.00 (65%)

Question 1
Correct

Mark 1.00 out of 1.00

When we implement the Runnable interface, we must define the method

a. run() 

b. runnable()

c. start()

d. init()

The correct answer is:


run()

Question 2
Incorrect

Mark 0.00 out of 1.00

yield() methods causes which of the following

a. Currently running thread is moved from 'running' to 'read to run' state

b. None of the above

c. Terminates a 'running'' thread 

d. Currently 'ready to run' thread to 'running' thread

The correct answer is:


Currently running thread is moved from 'running' to 'read to run' state


Question 3

Correct

Mark 1.00 out of 1.00

Predict the output of the following program.


abstract class demo

{
public int a;

demo()
{

a = 10;

abstract public void set();

abstract final public void get();

class Test extends demo

public void set(int a)


{

this.a = a;
}

final public void get()

{
System.out.println("a = " + a);

public static void main(String[] args)


{

Test obj = new Test();


obj.set(20);

obj.get();
}

a. a=10; a=20;

b. a=10

c. a=20

d. Compilation Error 

The correct answer is:


Compilation Error

Question 4
Correct

Mark 1.00 out of 1.00

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 

The correct answer is:


super

Question 5
Correct

Mark 1.00 out of 1.00

The programmer must explicitly create the System.in and System.out objects.

Select one:
True

False 

The correct answer is 'False'.


Question 6

Incorrect

Mark 0.00 out of 1.00

When the same method call may at different times invoke different methods based on the dynamic type, this is called 

Answer: Overloading 

The correct answer is: polymorphism

Question 7
Correct

Mark 1.00 out of 1.00

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

The correct answer is:


Private

Question 8
Correct

Mark 1.00 out of 1.00

Which of the following statements is true concerning objects and/or classes? 

a. A class encapsulates only data.

b. A class is an instance of an object.

c. An object is an instance of a class. 

d. An object encapsulates only data.

The correct answer is:


An object is an instance of a class.


Question 9

Incorrect

Mark 0.00 out of 1.00

Abstract class can have constructors and static methods?

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

The correct answer is:


True

Question 10
Correct

Mark 1.00 out of 1.00

Composition is a stronger form of which of the following?

a. Encapsulation

b. Aggregation 

c. Inheritance

d. All of the above

The correct answer is:


Aggregation

Question 11
Correct

Mark 1.00 out of 1.00

The ............ type of variable must be initialized while declaring.

Answer: final 

The correct answer is: final


Question 12

Incorrect

Mark 0.00 out of 1.00

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 

The correct answer is 'True'.

Question 13
Correct

Mark 1.00 out of 1.00

-------------- keyword allows us to define one class as an extension of another.

Answer: extends 

The correct answer is: extends

Question 14
Correct

Mark 1.00 out of 1.00

An object of multi-level inherited abstract class can not be created in memory.

Select one:
True 

False

The correct answer is 'True'.


Question 15

Correct

Mark 1.00 out of 1.00

What best describes the purpose of a class’s constructor?

a. Determines the amount of space needed for an object and creates the object.

b. None of the above

c. Names the new object

d. Initialize the fields in the object. 

The correct answer is:


Initialize the fields in the object.

Question 16
Correct

Mark 1.00 out of 1.00

Which is correct syntax for creating an object of Class in Java?

a. classname objectname= new classname;

b. classname objectname= new() classname();

c. classname objectname= new() integer;

d. classname objectname= new classname(); 

The correct answer is:


classname objectname= new classname();


Question 17

Correct

Mark 1.00 out of 1.00

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

The correct answer is:


run


Question 18

Incorrect

Mark 0.00 out of 1.00

What type of relationship is presented in the following program

a. an 'is-a' relationship

b. a 'has-a' relationship

c. Niether 

d. both

The correct answer is:


a 'has-a' relationship


Question 19

Incorrect

Mark 0.00 out of 1.00

Aggregation is which of the following?

a. Expresses a part-of relationship and is a stronger form of an association relationship.

b. Expresses a part-of relationship and is a weaker form of an association relationship.

c. Expresses an is-a relationship and is a weaker form of an association relationship.

d. Expresses an is-a relationship and is a stronger form of an association relationship. 

The correct answer is:


Expresses a part-of relationship and is a stronger form of an association relationship.

Question 20
Incorrect

Mark 0.00 out of 1.00

The methods wait() and notify() are defined in

a. java.lang.Object

b. java.lang.Runnable

c. java.lang.String

d. java.lang.Thread 

The correct answer is:


java.lang.Object


Question 21

Correct

Mark 1.00 out of 1.00

How many arguments are required in the definition of an overloaded unary operator?

a. None 

b. 3

c. 1

d. 2

The correct answer is:


None

Question 22
Correct

Mark 1.00 out of 1.00

Does Constructors create an Object?

a. No 

b. Yes

The correct answer is:


No


Question 23

Correct

Mark 1.00 out of 1.00

Which of the following is FALSE about abstract classes in Java

a.  Abstract classes can have constructors

b.
A class can be made abstract without any abstract method

c. A class can inherit from multiple abstract classes. 

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

The correct answer is:


A class can inherit from multiple abstract classes.

Question 24
Incorrect

Mark 0.00 out of 1.00

Two methods cannot have the same name in Java.

Select one:
True 

False

The correct answer is 'False'.


Question 25

Incorrect

Mark 0.00 out of 1.00

In an Interface

a. Only one of its methods is abstract method 

b. All of its methods are abstract

c. Some methods are abstract and some are concrete

d. There are no methods

The correct answer is:


All of its methods are abstract

Question 26
Incorrect

Mark 0.00 out of 1.00

In multilevel inheritance, the last subclass inherits all methods and variables of

a. Few classes selected based on the Java compiler version

b. The immediate Superclass

c. All classes above it 

d. None of the above

The correct answer is:


The immediate Superclass


Question 27

Correct

Mark 1.00 out of 1.00

Which of the following is True for Threads

a. Threads have their own heap allocated area.

b. None of the above

c. Threads doesn't have own stack.

d. Threads have their own stack. 

The correct answer is:


Threads have their own stack.


Question 28

Correct

Mark 1.00 out of 1.00

What should be the correct output of the following program,

a. hello
world

b. Hi

hello

world

c. Hi  

Hi

d. Hi hello
Hi world

The correct answer is:


Hi 
Hi

Question 29
Incorrect

Mark 0.00 out of 1.00

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

The correct answer is 'False'.

Question 30

Incorrect

Mark 0.00 out of 1.00

Any class may be inherited by another class in the same package

a. True

b. Depends upon the specific Access specifier

c. False 

d. Depends upon the Java version

The correct answers are:


True,
Depends upon the specific Access specifier


Question 31

Correct

Mark 1.00 out of 1.00

Which of the following is true about interfaces in java.


1) An interface can contain the following type of members.
....public, static, final fields (i.e., constants) 
....default and static methods with bodies

2) An instance of the interface can be created.

3) A class can implement multiple interfaces.


4) Many classes can implement the same interface.

a. 1, 3, and 4 

b. 1, 2, and 4

c. 2, 3, and 4

d. 1, 2, 3, and 4

The correct answer is:

1, 3, and 4

Question 32
Incorrect

Mark 0.00 out of 1.00

start() method is used for which of the following

a. Invoke the thread, before the run method is executed.

b. Execute the thread which is in 'ready to run' state 

c. Transit the thread from 'running' to 'ready to run' state

The correct answer is:


Invoke the thread, before the run method is executed.


Question 33

Correct

Mark 1.00 out of 1.00

A subclass can --------------- a superclass method by declaring a method with the same signature as the superclass method.

Answer: override 

The correct answer is: Override

Question 34
Correct

Mark 1.00 out of 1.00

The keyword used to call methods in the superclass is ----------- .

Answer: super 

The correct answer is: super

Question 35
Correct

Mark 1.00 out of 1.00

Can we return ‘this’ keyword from a method?

a. No

b. Yes 

The correct answer is:


Yes


Question 36

Correct

Mark 1.00 out of 1.00

The object-oriented development life cycle is which of the following?

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. 

The correct answer is:


Analysis, design, and implementation steps in the given order and using multiple iterations.


Question 37

Incorrect

Mark 0.00 out of 1.00

What is the output of this program,

class check {

public static void main(String[] args)

{
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

The correct answer is:


10    20

Question 38
Correct

Mark 1.00 out of 1.00

It is an error if a class with one or more abstract methods is not explicitly declared as abstract.

Select one:
True 

False

The correct answer is 'True'.


Question 39

Incorrect

Mark 0.00 out of 1.00

When would you use a private constructor?

a. If you want to protect your class’s members from outside modification 

b. When you get bored with public

c. Never, it's not allowed

d. If you want to disallow instantiation of that class from outside that class

The correct answer is:


If you want to disallow instantiation of that class from outside that class

Question 40
Correct

Mark 1.00 out of 1.00

A synchronized method can be used by

a. One Thread at a time 

b. Multiple threads concurrently

The correct answer is:


One Thread at a time


Question 41

Incorrect

Mark 0.00 out of 1.00

What will be the output of the following class?


class B 

{
   int b; 

   public B(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

The correct answer is:


0


Question 42

Correct

Mark 1.00 out of 1.00

Which of the following is a Deadlock condition in Java?

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.

d. A situation where two threads waiting to get terminated.

The correct answer is:


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.

Question 43
Correct

Mark 1.00 out of 1.00

The synchronized keyword is used to prevent Deadlock.

Select one:
True 

False

The correct answer is 'True'.


Question 44

Correct

Mark 1.00 out of 1.00

Packages are a collection of

a. All of the above

b. Attributes

c. Classes and Interfaces 

d. Classes

The correct answers are:


Classes,

Classes and Interfaces

Question 45
Correct

Mark 1.00 out of 1.00

How many Threads can a Process have?

a. Equal to the number of classes

b. Multiple 

c. Equal to the number of methods

d. 1

The correct answer is:


Multiple


Question 46

Correct

Mark 1.00 out of 1.00

Which of the following statements are True?

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.

d. Instance methods may access local variables of static methods.

e. A static method can call other non-static methods in the same class by using the 'this' keyword.

The correct answers are:


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 47
Correct

Mark 1.00 out of 1.00

The ------------ type of variable can be accessed using classname.

Answer: static 

The correct answer is: static


Question 48

Correct

Mark 1.00 out of 1.00

Operator overloading is

a. Giving C++ operators more operands than usual

b. Making new C++ operators

c. Giving new meanings to existing C++ operators 

d. Making C++ operators work with objects

The correct answers are:


Making C++ operators work with objects,
Giving new meanings to existing C++ operators

Question 49
Incorrect

Mark 0.00 out of 1.00

Abstract class support _____________ inheritance in Java.

a. Multiple Inheritance 

b. Multilevel Inheritance

The correct answer is:


Multilevel Inheritance


Question 50

Correct

Mark 1.00 out of 1.00

What is the output of the following Java program,

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

The correct answer is:


20

Question 51
Incorrect

Mark 0.00 out of 1.00

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 

The correct answer is:


this


Question 52

Incorrect

Mark 0.00 out of 1.00

 Which of the following is correct related to the below program,


class Base {

  public final void show() {


       System.out.println("Base::show() called");

    }
}

class Derived extends Base {

    public void show() { 


       System.out.println("Derived::show() called");

    }
}

public class Main {


    public static void main(String[] args) {

        Base b = new Derived();

        b.show();
    }

a. Base::show() called

b. Exception

c. Compiler Error

d. Derived::show() called 

The correct answer is:


Compiler Error


Question 53

Correct

Mark 1.00 out of 1.00

Choose the correct line of code which should be used to start the Thread

a. Thread t = new Thread(); x.run();

b. X run = new X(); Thread t = new Thread(run); t.start(); 

c. Thread t = new Thread(X);

d. Thread t = new Thread(X); t.start();

The correct answer is:


X run = new X(); Thread t = new Thread(run); t.start();


Question 54

Correct

Mark 1.00 out of 1.00

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.

d. Create classes for each

e. Create one class PublishedMaterial with the requested fields plus type.

The correct answer is:

Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.

Question 55

Correct

Mark 1.00 out of 1.00

All methods in an abstract class must be declared as abstract.

Select one:
True

False 

The correct answer is 'False'.

◄ OFFLINE STUDENTS Pre-End Semester Examination

Jump to...

OFFLINE STUDENTS _ End Semester Examination ►


Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Mid Semester Examination / Mid Semester Online Examination

Started on Wednesday, 10 November 2021, 9:00 AM


State Finished
Completed on Wednesday, 10 November 2021, 9:40 AM
Time taken 40 mins
Marks 24.00/35.00
Grade 6.86 out of 10.00 (69%)

Question 1
Correct

Mark 1.00 out of 1.00

In the following code, how many times ‘this’ would be created,

class A 
 {

   public static void main (String[] args) 

    { 
      A x = new A();

      A y = new A();


    }

a. 1

b. 2 

c. 3

d. 0

The correct answer is:


2
Question 2

Correct

Mark 1.00 out of 1.00

Which keyword is used for accessing the features of a package?

a. Package

b. Extends

c. Export

d. Import 

The correct answer is:


Import

Question 3
Correct

Mark 1.00 out of 1.00

Abstract class can have constructors and static methods?

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

The correct answer is:


True

Question 4
Correct

Mark 1.00 out of 1.00

Static methods can be overloaded.

Select one:
True 

False

The correct answer is 'True'.


Question 5

Correct

Mark 1.00 out of 1.00

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 classes for each

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.

The correct answer is:

Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.

Question 6

Incorrect

Mark 0.00 out of 1.00

Which of the following is FALSE about abstract classes in Java

a. A class can inherit from multiple abstract classes.

b.
A class can be made abstract without any abstract method 

c. Abstract classes can have constructors  

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

The correct answer is:


A class can inherit from multiple abstract classes.
Question 7

Incorrect

Mark 0.00 out of 1.00

Any class may be inherited by another class in the same package

a. Depends upon the specific Access specifier

b. Depends upon the Java version

c. False 

d. True

The correct answers are:


True,

Depends upon the specific Access specifier

Question 8
Correct

Mark 1.00 out of 1.00

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

The correct answer is:


Encapsulation
Question 9

Correct

Mark 1.00 out of 1.00

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 {  

      public void myMethod()   


    {  

    System.out.println("Method");  
    }  

      

    {  
    System.out.println(" Instance Block");  

    }  
          

    public void First_C()  


    {  

    System.out.println("Constructor ");  

    }  
    static {  

        System.out.println("static block");  
    }  

    public static void main(String[] args) {  


    First_C c = new First_C();  

    c.First_C();  
    c.myMethod();  

  }  

}   

a.
Instance block, method, static block, and constructor

b. Static block, instance block, constructor, and method 

c. Static block, method, instance block, and constructor

d. Method, constructor, instance block, and static block

The correct answer is:


Static block, instance block, constructor, and method
Question 10

Correct

Mark 1.00 out of 1.00

Which of the following cannot have ‘this’ keyword inside it

a. Non static methods

b. Constructors

c. Static methods and blocks 

The correct answer is:


Static methods and blocks

Question 11
Correct

Mark 1.00 out of 1.00

We can overload methods with differences only in their return type

Select one:
True

False 

The correct answer is 'False'.

Question 12
Correct

Mark 1.00 out of 1.00

Private member of a class is visible to

a. Same Package

b. Subclass

c. Same class 

d. Everyone

The correct answer is:


Same class
Question 13

Incorrect

Mark 0.00 out of 1.00

 Which of the following is correct related to the below program,


class Base {

  public final void show() {


       System.out.println("Base::show() called");

    }
}

class Derived extends Base {

    public void show() { 


       System.out.println("Derived::show() called");

    }
}

public class Main {


    public static void main(String[] args) {

        Base b = new Derived();

        b.show();
    }

a. Exception

b. Compiler Error

c. Derived::show() called 

d. Base::show() called

The correct answer is:


Compiler Error
Question 14

Correct

Mark 1.00 out of 1.00

Abstract class support _____________ inheritance in Java.

a. Multiple Inheritance

b. Multilevel Inheritance 

The correct answer is:


Multilevel Inheritance
Question 15

Correct

Mark 1.00 out of 1.00

What will be the output of the following Java code?

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 

The correct answer is:


Compilation Error
Question 16

Correct

Mark 1.00 out of 1.00

Which of the following is TRUE about Interfaces in Java,

1) An interface can contain the following type of members.


....public, static, final fields (i.e., constants) 

....default and static methods with bodies

2) An instance of the interface can be created.

3) A class can implement multiple interfaces.

4) Many classes can implement the same interface.

a. 1, 2, 3, and 4

b. 2, 3, and 4

c. 1, 3, and 4 

d. 1, 2, and 4

The correct answer is:


1, 3, and 4

Question 17
Correct

Mark 1.00 out of 1.00

How many arguments are required in the definition of an overloaded unary operator?

a. 2

b. 3

c. None 

d. 1

The correct answer is:


None
Question 18

Correct

Mark 1.00 out of 1.00

Which of the following statements are True?

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. Instance methods may access local variables of static methods.

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. 

The correct answers are:


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 19
Correct

Mark 1.00 out of 1.00

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

The correct answer is:


super
Question 20

Incorrect

Mark 0.00 out of 1.00

In multilevel inheritance, the last subclass inherits all methods and variables of

a. Few classes selected based on the Java compiler version

b. None of the above

c. All classes above it 

d. The immediate Superclass

The correct answer is:


The immediate Superclass
Question 21

Incorrect

Mark 0.00 out of 1.00

How many instance initializers are in this code?

public class Bowling {

 { 
     System.out.println(); 

 }
 public Bowling () {

    System.out.println();
 }

 static { 

    System.out.println(); 
 }

 { 
     System.out.println(); 

 }
}

a. Two

b. One 

c. None

d. Three

The correct answer is:


Two
Question 22

Correct

Mark 1.00 out of 1.00

An object of multi-level inherited abstract class can not be created in memory.

Select one:
True 

False

The correct answer is 'True'.

Question 23
Correct

Mark 1.00 out of 1.00

Given that Student is a class, how many reference variables and objects are created by the following code?

Student studentName, studentId;  


studentName = new Student();  

Student stud_class = new Student(); 

a. Three reference variables and two objects are created. 

b. Three reference variables and three objects are created.

c. Two reference variables and two objects are created.

d. One reference variable and two objects are created.

The correct answer is:


Three reference variables and two objects are created.
Question 24

Correct

Mark 1.00 out of 1.00

What is the output of the following code,

class TestRunner {  


  static public int succeeded;

  static public int failed;

  
  public TestRunner() {    

  }
  

  public TestRunner(int s, int f) {


    succeeded=s; failed=f;

  }
  

  public void display() {

      System.out.println(succeeded + " " + failed);


  }

class check {

  public static void main(String[] args) {

    TestRunner tr = new TestRunner(1, 99);


    TestRunner.succeeded = 99;

    tr.display();
  }

a. 99   99 

b. 1   99

c. 0   0

d. 99   0

The correct answer is:


99   99
Question 25

Incorrect

Mark 0.00 out of 1.00

The concept of multiple inheritance is implemented in C++ by

a. Extending one class and implementing one or more interfaces

b. Extending two or more classes

c. Implementing two or more interfaces 

d. All of the above

The correct answer is:


Extending two or more classes

Question 26
Correct

Mark 1.00 out of 1.00

What is the output of the following Java program,

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 

The correct answer is:


20
Question 27

Correct

Mark 1.00 out of 1.00

Can we return ‘this’ keyword from a method?

a. No

b. Yes 

The correct answer is:


Yes

Question 28
Correct

Mark 1.00 out of 1.00

What is the output of this program,

class check {

public static void main(String[] args)


{

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

The correct answer is:


10    20
Question 29

Correct

Mark 1.00 out of 1.00

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

ii. getld is implemented in the subclass


iii. getName is an abstract function in the superclass

iv. getName is implemented in the superclass


v. getName is implemented in the subclass

vi. getSalary is an abstract function in the superclass

vii. getSalary is implemented in the superclass


viii. getSalary is implemented in the subclass

CHOOSE THE BEST DESIGN AMONG THE FOLLOWING OPTIONS;

a. (i), (iii), (v), (vi), (viii)

b. (i), (iv), (vi), (viii) 

c. (i), (iv), (vii)

d. (ii), (v), (viii)

The correct answer is:


(i), (iv), (vi), (viii)
Question 30

Correct

Mark 1.00 out of 1.00

Aggregation is which of the following?

a. Expresses an is-a relationship and is a weaker form of an association relationship.

b. Expresses an is-a relationship and is a stronger form of an association relationship.

c. Expresses a part-of relationship and is a weaker form of an association relationship.

d. Expresses a part-of relationship and is a stronger form of an association relationship. 

The correct answer is:


Expresses a part-of relationship and is a stronger form of an association relationship.
Question 31

Incorrect

Mark 0.00 out of 1.00

What will be the output of the following class?


class B 

{
   int b; 

   public B(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

The correct answer is:


0
Question 32

Incorrect

Mark 0.00 out of 1.00

Does Constructors create an Object?

a. Yes 

b. No

The correct answer is:


No

Question 33
Incorrect

Mark 0.00 out of 1.00

What would be the output of the following code?


public class check

public static void main(String args[])


{

boolean b = true;
System.out.println("CSE");

return;
System.out.println("ESC");

}
}

a. CSE 

b. ESC

c. CSE followed by ESC

d. Compiler Error

The correct answer is:


Compiler Error
Question 34

Not answered

Marked out of 1.00

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

The correct answer is:


this
Question 35

Not answered

Marked out of 1.00

What would be the output of the following program?

abstract class demo


{

public int a;

demo()
{

a = 10;
}

abstract public void set();

abstract final public void get();

class Test extends demo

public void set(int a)

{
this.a = a;

final public void get()


{

System.out.println("a = " + a);


}

public static void main(String[] args)

{
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

◄ Pre-mid Semester Quiz Test

Jump to...

OFFLINE STUDENTS Pre-End Semester Examination ►


Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Mid Semester Examination / Pre-mid Semester Quiz Test

Started on Thursday, 21 October 2021, 11:22 AM


State Finished
Completed on Thursday, 21 October 2021, 12:02 PM
Time taken 39 mins 59 secs
Marks 23.00/35.00
Grade 6.57 out of 10.00 (66%)

Question 1
Correct

Mark 1.00 out of 1.00

When does method overloading is determined?

a. Run time

b. Coding time

c. Execution time

d. Compile time 

The correct answer is:


Compile time


Question 2

Correct

Mark 1.00 out of 1.00

Aggregation is which of the following?

a. Expresses an is-a relationship and is a stronger form of an association relationship.

b. Expresses a part-of relationship and is a weaker form of an association relationship.

c. Expresses an is-a relationship and is a weaker form of an association relationship.

d. Expresses a part-of relationship and is a stronger form of an association relationship. 

The correct answer is:


Expresses a part-of relationship and is a stronger form of an association relationship.

Question 3
Correct

Mark 1.00 out of 1.00

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.

d. Create classes for each

e. Create one class PublishedMaterial with the requested fields plus type.

The correct answer is:

Create the class PublishedMaterial with children classes of Book, Movie, and AudioTape.


Question 4

Correct

Mark 1.00 out of 1.00

Private member of a class is visible to

a. Everyone

b. Same class 

c. Subclass

d. Same Package

The correct answer is:


Same class


Question 5

Incorrect

Mark 0.00 out of 1.00

Predict the output of the following Java program?


class Test 

{
  int i;


class Main 

   public static void main(String args[]) { 


     Test t; 

     System.out.println(t.i); 
}

a. 0

b. Compiler Error

c. Run time error 

d. Garbage Value

The correct answer is:


Compiler Error


Question 6

Correct

Mark 1.00 out of 1.00

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

ii. getld is implemented in the subclass


iii. getName is an abstract function in the superclass

iv. getName is implemented in the superclass


v. getName is implemented in the subclass

vi. getSalary is an abstract function in the superclass

vii. getSalary is implemented in the superclass


viii. getSalary is implemented in the subclass

CHOOSE THE BEST DESIGN AMONG THE FOLLOWING OPTIONS;

a. (i), (iii), (v), (vi), (viii)

b. (i), (iv), (vi), (viii) 

c. (ii), (v), (viii)

d. (i), (iv), (vii)

The correct answer is:


(i), (iv), (vi), (viii)


Question 7

Correct

Mark 1.00 out of 1.00

Which of the following statements is true concerning objects and/or classes? 

a. An object encapsulates only data.

b. An object is an instance of a class. 

c. A class encapsulates only data.

d. A class is an instance of an object.

The correct answer is:


An object is an instance of a class.

Question 8
Correct

Mark 1.00 out of 1.00

Two methods cannot have the same name in Java.

Select one:
True

False 

The correct answer is 'False'.


Question 9

Correct

Mark 1.00 out of 1.00

What best describes the purpose of a class’s constructor?

a. Determines the amount of space needed for an object and creates the object.

b. None of the above

c. Names the new object

d. Initialize the fields in the object. 

The correct answer is:


Initialize the fields in the object.

Question 10
Correct

Mark 1.00 out of 1.00

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.

d. Both I and II are correct.

The correct answer is:

Neither I nor II is correct.


Question 11

Correct

Mark 1.00 out of 1.00

Composition is a stronger form of which of the following?

a. Encapsulation

b. Aggregation 

c. Inheritance

d. All of the above

The correct answer is:


Aggregation

Question 12
Correct

Mark 1.00 out of 1.00

Operator overloading is

a. Making new C++ operators

b. Giving C++ operators more operands than usual

c. Making C++ operators work with objects

d. Giving new meanings to existing C++ operators 

The correct answers are:


Making C++ operators work with objects,

Giving new meanings to existing C++ operators


Question 13

Correct

Mark 1.00 out of 1.00

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

The correct answer is:


Encapsulation

Question 14
Incorrect

Mark 0.00 out of 1.00

Any class may be inherited by another class in the same package

a. True

b. False 

c. Depends upon the Java version

d. Depends upon the specific Access specifier

The correct answers are:


True,

Depends upon the specific Access specifier


Question 15

Correct

Mark 1.00 out of 1.00

What would be the output of the following code;


public class check

{
public static void main(String args[])

{
boolean b = true;

System.out.println("CSE");

if (!b)
return;

System.out.println("ESC");
}

a. CSE followed by ESC 

b. CSE

c. Compiler Error

d. ESC

The correct answer is:


CSE followed by ESC

Question 16
Incorrect

Mark 0.00 out of 1.00

Does Constructors create an Object?

a. No

b. Yes 

The correct answer is:


No


Question 17

Correct

Mark 1.00 out of 1.00

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

The correct answer is:


Protected

Question 18
Correct

Mark 1.00 out of 1.00

We can overload methods with differences only in their return type

Select one:
True

False 

The correct answer is 'False'.


Question 19

Correct

Mark 1.00 out of 1.00

Predict the output of the following Java program?

class demo
{

    int a, b;

     demo()
    {

        a = 10;
        b = 20;

    }
    

    public void print()


    {

        System.out.println ("a = " + a + " b = " + b + "n");

    }
}

 
class Test

{
 

    public static void main(String[] args)

    {
        demo obj1 = new demo();

        demo obj2 = obj1;


 

        obj1.a += 1;
        obj1.b += 1;

 
        System.out.println ("values of obj1 : ");

        obj1.print();

        System.out.println ("values of obj2 : ");


        obj2.print();

 
    }

a. values of obj1: a = 11 b = 20 

values of obj2: a = 10 b = 21


b. Compiler Error

c. values of obj1: a = 11 b = 21  

values of obj2: a = 11 b = 21

d. values of obj1: a = 11 b = 21 

values of obj2: a = 10 b = 20

The correct answer is:


values of obj1: a = 11 b = 21 

values of obj2: a = 11 b = 21

Question 20
Correct

Mark 1.00 out of 1.00

The object-oriented development life cycle is which of the following?

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.

The correct answer is:


Analysis, design, and implementation steps in the given order and using multiple iterations.


Question 21

Correct

Mark 1.00 out of 1.00

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

The correct answer is:


Private

Question 22
Correct

Mark 1.00 out of 1.00

How many different types of access specifiers are possible in Java?

Answer: 4 

The correct answer is: 4

Question 23
Incorrect

Mark 0.00 out of 1.00

The concept of multiple inheritance is implemented in C++ by

a. Implementing two or more interfaces

b. Extending two or more classes

c. All of the above

d. Extending one class and implementing one or more interfaces 

The correct answer is:


Extending two or more classes


Question 24

Correct

Mark 1.00 out of 1.00

Consider the following two statements: 


(a) A publicly derived class is a subtype of its base class. 

(b) Inheritance provides for code reuse.

a. Statement (a) is correct and (b) is incorrect

b. Statement (a) is incorrect and (b) is correct

c. Neither of the statements (a) and (b) are correct

d. Both the statements (a) and (b) are correct. 

The correct answer is:


Both the statements (a) and (b) are correct.

Question 25
Incorrect

Mark 0.00 out of 1.00

Packages are a collection of

a. Classes and Interfaces

b. All of the above 

c. Classes

d. Attributes

The correct answers are:


Classes,
Classes and Interfaces


Question 26

Correct

Mark 1.00 out of 1.00

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 

The correct answer is 'False'.

Question 27
Incorrect

Mark 0.00 out of 1.00

How many arguments are required in the definition of an overloaded unary operator?

a. 2

b. 3

c. None

d. 1 

The correct answer is:


None

Question 28
Correct

Mark 1.00 out of 1.00

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

The correct answer is 'True'.


Question 29

Incorrect

Mark 0.00 out of 1.00

In multilevel inheritance, the last subclass inherits all methods and variables of

a. All classes above it 

b. None of the above

c. Few classes selected based on the Java compiler version

d. The immediate Superclass

The correct answer is:


The immediate Superclass

Question 30
Correct

Mark 1.00 out of 1.00

The benefits of object-oriented modeling are which of the following?

a. All of the above 

b. Improved communication between users, analysts, etc. 

c.
Reusability of analysis, design, and programming results 

d. The ability to tackle more challenging problems 

The correct answer is: All of the above


Question 31

Incorrect

Mark 0.00 out of 1.00

A normal method in a subclass must always invoke its super class constructor in its first statement

a. False 

b. True

c. Methodology not possible

d. Depends upon the Java compiler

The correct answer is:


Methodology not possible

Question 32
Incorrect

Mark 0.00 out of 1.00

What would be the output of the following code?

public class check


{

public static void main(String args[])


{

boolean b = true;
System.out.println("CSE");

return;

System.out.println("ESC");
}

a. CSE followed by ESC 

b. CSE

c. ESC

d. Compiler Error

The correct answer is:


Compiler Error


Question 33

Incorrect

Mark 0.00 out of 1.00

What would be the output of the following Java program:

class one1
{

one1()
{

System.out.println("Hello");
}

class two2 extends one1


{

public class check {

public static void main(String[] args)

{
two2 t = new two2();

a. Hello

b. Compiler Error. 

c. Hello Hello

d. Blank. No output. 

The correct answer is:


Hello


Question 34

Incorrect

Mark 0.00 out of 1.00

It is an error to have a method with the same signature in both the super class and its subclass

Select one:
True 

False

The correct answer is 'False'.

Question 35
Incorrect

Mark 0.00 out of 1.00

When would you use a private constructor?

a. If you want to protect your class’s members from outside modification 

b. If you want to disallow instantiation of that class from outside that class

c. When you get bored with public

d. Never, it's not allowed

The correct answer is:


If you want to disallow instantiation of that class from outside that class

◄ Weekly Quiz 2

Jump to...

Mid Semester Online Examination ►


Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Continuous Evaluation / Weekly Quiz 2

Started on Wednesday, 13 October 2021, 8:55 AM


State Finished
Completed on Wednesday, 13 October 2021, 9:00 AM
Time taken 4 mins 46 secs
Marks 4.00/6.00
Grade 3.33 out of 5.00 (67%)

Question 1
Correct

Mark 1.00 out of 1.00

Choose the correct output of the following program;

public class test_int_double {


void display(int x)

{
System.out.println("Integer");

}
void display(double x)

System.out.println("Double");
}

public static void main(String args[])


{

test_int_double t = new test_int_double();


t.display(5.0);

}
}

a. Double 

b. Error in compilation

c. None of the above

d. Integer

The correct answer is:


Double


Question 2

Correct

Mark 1.00 out of 1.00

How many parameters does a Default constructor have?

a. Depends upon other overloaded Constructors

b. Multiple

c. None 

d. 1

The correct answer is:


None

Question 3
Incorrect

Mark 0.00 out of 1.00

Aggregation is which of the following?

a. Expresses an is-a relationship and is a weaker form of an association relationship.

b. Expresses an is-a relationship and is a stronger form of an association relationship. 

c. Expresses a part-of relationship and is a weaker form of an association relationship.

d. Expresses a part-of relationship and is a stronger form of an association relationship.

The correct answer is: Expresses a part-of relationship and is a stronger form of an association relationship.


Question 4

Correct

Mark 1.00 out of 1.00

The fact that the same operation may apply to two or more classes is called what?

a. All of the above

b. Multiple Classification

c. Encapsulation

d. Polymorphism 

The correct answer is:


Polymorphism

Question 5
Correct

Mark 1.00 out of 1.00

Which of the following applies to a class rather than an object?

a. Scope 

b. Update

c. Query

d. Constructor

The correct answer is:


Scope


Question 6

Incorrect

Mark 0.00 out of 1.00

How many Overloaded methods are available in the following code;

class test 
{
    void display(int x) 
      { 
         System.out.println(“CSE”); 
       }
    int display(int x) 

      { 
         return 5; 
      } 
}

a. 1 

b. 2

c. 3

d. 0

The correct answer is:


0

◄ Weekly Quiz 1

Jump to...

Pre-mid Semester Quiz Test ►


Dashboard / Courses / Autumn 2021-22 / BTech Sem-3 / CS 201 / Continuous Evaluation / Weekly Quiz 1

Started on Wednesday, 29 September 2021, 8:55 AM


State Finished
Completed on Wednesday, 29 September 2021, 9:00 AM
Time taken 5 mins 1 sec
Marks 4.00/6.00
Grade 3.33 out of 5.00 (67%)

Question 1
Correct

Mark 1.00 out of 1.00

What is the correct way of creating instances of a class “student”?

a. student shivam = new student()

b. shivam = create student();

c. student shivam = new student(); 

d. Student shivam = new student;

Your answer is correct.

The correct answer is:


student shivam = new student();

Question 2

Correct

Mark 1.00 out of 1.00

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

Your answer is correct.

The correct answer is:


Polymorphism

Question 3

Correct

Mark 1.00 out of 1.00

How many objects can be declared of a specific class in a single program?

a. 127

b. As many as you want 

c. 32768

d. 1

Your answer is correct.


The correct answer is: As many as you want

Question 4
Incorrect

Mark 0.00 out of 1.00

Which of the following best defines a class?

a. Parent of an object 

b. Instance of an object

c. Blueprint of an object

d. Scope of an object

Your answer is incorrect.

The correct answer is:


Blueprint of an object


Question 5

Correct

Mark 1.00 out of 1.00

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

Your answer is correct.

The correct answer is:


attributes, methods

Question 6
Incorrect

Mark 0.00 out of 1.00

Which of the following concepts of OOPS means exposing only necessary information to clients?

a. Data Binding

b. Abstraction

c. Encapsulation 

d. Data Hiding

Your answer is incorrect.


The correct answer is:
Abstraction

◄ Announcements

Jump to...

Weekly Quiz 2 ►

You might also like