Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

Question 1

1 / 1 pts
Which concept of Java is achieved by combining methods and attribute into a class?

  
Encapsulation
 

  
Inheritance
 

  
Polymorphism
 

  
Abstraction
 
 
Question 2
1 / 1 pts
Which of the following is a mechanism by which object acquires the properties of
another object?

  
Inheritance
 

  
Abstraction
 

  
Encapsulation
 

  
Polymorphism
 
 
Question 3
1 / 1 pts
Select correct statements about class(es).
  
A nested class is class which is declared inside a class.
 

  
A class can be declared inside a interface.
 

  
All
 

  
A class declaration defines a new reference type and how they are implemented.
 

  
A top level class is a class that is not a nested class.
 
 
Question 4
1 / 1 pts
OOP describes the task to be performed on objects.

  
false
 

  
true
 
 
Question 5
1 / 1 pts
How do I print out numbers on JAVA?

  
System.out.println('#');

  
System.out.println("#");

  
System.out.println(false);
 
  
System.out.println(#);
 
 
IncorrectQuestion 6
0 / 1 pts
Instance Variables are variables stored in the class and are available to all objects of a
class or objects of other classes if access is permitted

  
false
 

  
true
 
 
Question 7
1 / 1 pts
this - It represents an instance of the class in which it appears

  
true
 

  
false
 
 
IncorrectQuestion 8
0 / 1 pts
Access (Getter) – a method that is used to access or retrieve data.

  
true
 

  
false
 
 
Question 9
1 / 1 pts
this keyword can be passed as an argument in the method call.

  
false
 

  
true
 
 
IncorrectQuestion 10
0 / 1 pts
________ – a method that is automatically executed when an object is created. This
method is used to initialize the attributes.

  
Default
 

  
Custom
 

  
Constructor
 
 
Question 11
1 / 1 pts
While using encapsulation, which among the following is possible?

  
Data member's type can't be changed, or whole code have to be changed

  
Data member's data type can be changed without changing any other code

  
Member functions can be used to change the data type of data members
 

  
Code modification can be additional overhead
 
 
IncorrectQuestion 12
0 / 1 pts
Which of the following is not an advantage to using inheritance?

  
Enhancements to a base class will automatically be applied to derived classes.
 

  
One big superclass can be used instead of many little classes.
 

  
Similar classes can be made to behave consistently.
 

  
Code that is shared between classes needs to be written only once.
 
 
Question 13
1 / 1 pts
In Encapsulation, the programmer can change one part of the code without affecting
other parts

  
true
 

  
false
 
 
Question 14
1 / 1 pts
What type of inheritance does Java have?

  
Single Inheritance
 

  
Multiple Inheritance
 
  
Double Inheritance
 

  
Class Inheritance
 
 
Question 15
1 / 1 pts
There is no security of data with Encapsulation

  
false
 

  
true
 
 
IncorrectQuestion 16
0 / 1 pts
If a derived class object is created, which constructor is called first?

  
Base class constructor
 

  
Depends on how we call the object
 

  
Not possible
 

  
Derived class constructor
 
 
IncorrectQuestion 17
0 / 1 pts
Single level inheritance will be best for___________
  
Inheriting a class which can perform and print all calculations
 

  
Inheriting a class which performs all the calculations
 

  
Inheriting all the classes for different calculations
 

  
Inheriting a class which can print all the calculation results
 
 
IncorrectQuestion 18
0 / 1 pts
Which concept will result in derived class with more features (consider maximum 3
classes)?

  
Multiple inheritance
 

  
Single inheritance
 

  
Hierarchical inheritance
 

  
Multilevel inheritance
 
 
IncorrectQuestion 19
0 / 1 pts
Which among the following is correct for the following code?
 
class A

    public : class B
    {
        public : B(int i): data(i)
        {
        }
        int data;
    }
};
class C: public A
{
     class D:public A::B{ };
};

  
Multi-level inheritance is used, with nested classes

  
Single level inheritance is used, with enclosing classes

  
Single level inheritance is used, with both enclosing and nested classes

  
Multiple inheritance is used, with nested classes

 
IncorrectQuestion 20
0 / 1 pts
If base class contains 2 nested classes, will it be possible to implement single level
inheritance?

  
Yes, only if derived class also have nested classes
 

  
No, never
 
  
No, it will use more than 2 classes which is wrong
 

  
Yes, always
 

Question 1
1 / 1 pts
When does method overloading is determined?

  
At execution time
 

  
At coding time
 

  
At compile time
 

  
At run time
 
 
IncorrectQuestion 2
0 / 1 pts
Which of following statement(s) can result in new object instance creation if executed
successfully.

  
String str = "VirtuQ" + " "+ Simplifying Education";

  
int [] arr = {1,2,3,4,5};
 

  
All
 

  
String str = new String();
 
  
String str = new String("VirtuQ");
 
IncorrectQuestion 3
0 / 1 pts
The Scanner class contains a method called ___________ that reads user input that is
a integer.

  
Println
 

  
NextInt
 

  
pow
 

  
Length()
 
 
IncorrectQuestion 4
0 / 1 pts
Sally is continuing work on her Object-Oriented Program and is writing code for a car,
truck, and bus. These items under the class called vehicle are referred to as _____.

  
methods
 

  
objects
 

  
items
 

  
attributes
 
 
Question 5
1 / 1 pts
How do I print out numbers on JAVA?

  
System.out.println('#');

  
System.out.println("#");

  
System.out.println(false);
 

  
System.out.println(#);
 
 
Question 6
1 / 1 pts
Accessor (Getter) – a method that is used to access or retrieve data.

  
false
 

  
true
 
 
Question 7
1 / 1 pts
a variable that is accessible from all classes.

  
public variable
 

  
protected variable
 

  
private variable
 
 
Question 8
1 / 1 pts
this – contains a reference to the current object being constructed

  
false
 

  
true
 
 
IncorrectQuestion 9
0 / 1 pts
static Variables are variables stored in the class and are available to all objects of a
class or objects of other classes if access is permitted

  
false
 

  
true
 
 
Question 10
1 / 1 pts
a variable that is only accessible within a class where it is declared

  
private variable
 

  
public variable
 

  
protected variable
 
 
Question 11
1 / 1 pts
In Inheritance, the programmer can change one part of the code without affecting other
parts

  
true
 

  
false
 
 
Question 12
1 / 1 pts
If data members are private, what can we do to access them from the class object?

  
Create public member functions to access those data members
 

  
Create private member functions to access those data members
 

  
Create protected member functions to access those data members
 

  
Private data members can never be accessed from outside the class
 
 
IncorrectQuestion 13
0 / 1 pts
Encapsulation is also called as?

  
Data Hiding
 

  
Data Hidding
 

  
Data Encapsulation
 
  
None of the choices
 
 
Question 14
1 / 1 pts
Encapsulation is the way to add functions in a user defined structure.

  
True
 

  
False
 
 
Question 15
1 / 1 pts
Using encapsulation data security is ___________

  
Purely ensured
 

  
Very low
 

  
Not ensured
 

  
Ensured to some extent
 
 
Question 16
1 / 1 pts
Which type of inheritance cannot involve private inheritance?

  
All types can have private inheritance
 
  
Multiple
 

  
Hybrid
 

  
Single level
 
 
Question 17
1 / 1 pts
Which constructor will be called first from the classes involved in single inheritance from
object of derived class?

  
Derived class constructor
 

  
Both class constructors at a time
 

  
Base class constructor
 

  
Runtime error
 
 
Question 18
1 / 1 pts
Single level inheritance will be best for___________

  
Inheriting a class which can print all the calculation results
 

  
Inheriting a class which can perform and print all calculations
 

  
Inheriting a class which performs all the calculations
 

  
Inheriting all the classes for different calculations
 
 
Question 19
1 / 1 pts
If single inheritance is used, program will contain ________________

  
Exactly 2 classes
 

  
At least 2 classes
 

  
At most 4 classes
 

  
At most 2 classes
 
 
Question 20
1 / 1 pts
Which among the following is correct for the following code?
 
class A

    public : class B
    {
        public : B(int i): data(i)
        {
        }
        int data;
    }
};
class C: public A
{
     class D:public A::B{ };
};

  
Multi-level inheritance is used, with nested classes

  
Single level inheritance is used, with both enclosing and nested classes

  
Single level inheritance is used, with enclosing classes

  
Multiple inheritance is used, with nested classes

Question 1
1 / 1 pts
object-oriented programming, it is to break down a programming task into objects that
expose behavior (methods) and data (members or attributes) using interfaces.

  
true
 

  
false
 
 
Question 2
1 / 1 pts
________ is a technique of solving a problem and breaking it down into smaller parts
and solving each of the smaller problems.

  
Procedural Programming
 

  
OOP
 
 
Question 3
1 / 1 pts
Which one of these is a data type?

  
bit
 

  
gold
 

  
byte
 

  
fold
 
 
Question 4
1 / 1 pts
The Scanner class contains a method called ___________ that reads user input that is
a integer.

  
Println
 

  
NextInt
 

  
pow
 

  
Length()
 
 
IncorrectQuestion 5
0 / 1 pts
Which of following statement(s) can result in new object instance creation if executed
successfully.

  
String str = new String("VirtuQ");

  
String str = new String();
 

  
String str = "VirtuQ" + " "+ Simplifying Education";

  
All
 

  
int [] arr = {1,2,3,4,5};
 
 
IncorrectQuestion 6
0 / 1 pts
This - It represents an instance of the class in which it appears

  
false
 

  
true
 
 
Question 7
1 / 1 pts
final Class: a class that can never be sub-classed

  
true
 

  
false
 
 
Question 8
1 / 1 pts
Instance Variables are variables stored in each object of a class, usually referred to as
the non-static member fields of a class.

  
true
 

  
false
 
 
Question 9
1 / 1 pts
Constructor – a method that is automatically executed when an object is created. This
method is used to initialize the attributes.

  
true
 

  
false
 
 
Question 10
1 / 1 pts
Access (Getter) – a method that is used to access or retrieve data.

  
false
 

  
true
 
 
Question 11
1 / 1 pts
Which among the following best describes encapsulation?

  
It is a way of combining various data members and member functions that operate on
those data members into a single unit
 

  
It is a way of combining various member functions into a single unit
 

  
It is a way of combining various data members and member functions into a single unit
which can operate on any data
 

  
It is a way of combining various data members into a single unit
 
 
IncorrectQuestion 12
0 / 1 pts
Encapsulation is supported by ___________

  
None of the above
 

  
Classes
 

  
Methods
 

  
Objects
 
 
Question 13
1 / 1 pts
What type of inheritance does Java have?

  
Multiple Inheritance
 

  
Class Inheritance
 

  
Double Inheritance
 

  
Single Inheritance
 
 
Question 14
1 / 1 pts
Encapsulation has Better control of class attributes and methods

  
true
 

  
false
 
 
Question 15
1 / 1 pts
How can Encapsulation be achieved?

  
Using only private members
 

  
Using inheritance
 

  
Using Access Specifiers
 

  
Using Abstraction
 
 
Question 16
1 / 1 pts
Which among the following is correct for a hierarchical inheritance?

  
Two base classes can be used to be derived into one single class
 

  
One base class can be derived into other two derived classes or more
 

  
Two or more classes can be derived into one class
 

  
One base class can be derived into only 2 classes
 
 
Question 17
1 / 1 pts
How many classes can be inherited by a single class in java?

  
Only 255
 

  
Only 27
 

  
Only 1024
 

  
Only 1
 
 
IncorrectQuestion 18
0 / 1 pts
What is the output of the following program?
class A

            float sal=40000; 

class B extends A

            int salBonus=10000; 
            public static void main(String args[])
            { 
                        B p=new B(); 
                        System.out.println("B salary is:"+p.sal); 
                        System.out.println("Bonus of B is:"+p.bonus); 
            } 
}

  
Runtime error

  
B salary is 10000
Bonus of B is: 4000.0

  
Compile time error

  
B salary is: 4000.0
Bonus of B is: 10000

 
Question 19
1 / 1 pts
Which access type data gets derived as private member in derived class?
  
Private
 

  
Protected
 

  
Public
 

  
Protected and Private
 
 
Question 20
1 / 1 pts
Which language doesn't support single level inheritance?

  
Kotlin
 

  
C++
 

  
Java
 

  
All languages support it
 

You might also like