Quiz Question 1 (5 points) Which type of multiple inheritance does Java support?
ID: 3854845 • Letter: Q
Question
Quiz
Question 1 (5 points)
Which type of multiple inheritance does Java support?
Question 1 options:
Multiple inheritance of classes only
Multiple inheritance of both interfaces and classes
Multiple inheritance of interfaces only
Multiple inheritance of both interfaces and abstract classes
Save
Question 2 (5 points)
What is the lifetime of class variables in object-oriented languages?
Question 2 options:
The life of the method
The life of the package
The life of the class
The life of the statement
Save
Question 3 (5 points)
Which of the following statements is the most accurate regarding overloaded methods?
Question 3 options:
Overloaded methods have identical names
Overloaded methods have identical signatures
Two overloaded methods can never be in the same class
Inheritance is required for overloading
Save
Question 4 (5 points)
Which of the following statements is true about an Java abstract method or a C++ pure virtual function?
Question 4 options:
All of the above
It must have the return type void
It has no body
It cannot have any parameters
Save
Question 5 (5 points)
Which of the following is the lifetime of an instance variable?
Question 5 options:
The life of the program
The life of the class
The life of the method
The life of the object
Save
Question 6 (5 points)
Diamond inheritance can occur in which of the following kinds of languages?
Question 6 options:
Those that support multiple inheritance of interfaces
Those that support multiple inheritance of classes
Those that only support single inheritance
Those that support any type of inheritance
Save
Question 7 (5 points)
Which of the following is not a requirement for a language to be considered an object-oriented language?
Question 7 options:
Information hiding
Encapsulation
Concurrency
Inheritance
Polymorphism
Save
Question 8 (5 points)
In object-oriented languages, which type of cast is considered safe and does not need to be made explicit?
Question 8 options:
Up cast
Static cast
Both up and down casts
Down cast
Save
Question 9 (5 points)
When a Java method is overridden, how must the overriding method compare to the method that it overrides?
Question 9 options:
The names and return types must be identical
Only the names must be identical
The return types must be identical
The parameters must match in type, number and order
Save
Question 10 (5 points)
Which of the following is not true of an abstract class?
Question 10 options:
It can contain instance variables
It can contain ordinary methods
Objects of the class can be instantiated
It can contain abstract methods
Save
Question 11 (5 points)
Given the following Java method signature: int method(int param); Which of the following method signatures would be an acceptable signature to override the above method?
Question 11 options:
double method(double param);
int method(int param);
int method2(int param);
void method(int param);
Save
Question 12 (5 points)
In Java, who can not access a variable labeled with the access modifier protected?
Question 12 options:
Any method in the same package
Any method in a different package
Any method in any derived class
Any method in the same class
Save
Question 13 (5 points)
Which of the following pairs of terms are synonyms?
Question 13 options:
Parent class and superclass
Base class and subclass
Child class and superclass
Derived class and parent class
Save
Question 14 (5 points)
Which of the following is true about the methods of a Java nonstatic inner class?
Question 14 options:
They can only access instance variables of the inner class
The can only access class variables of the inner class
The can access instance variables of both the inner and outer class
They can only access instance variables of the outer class
Save
Question 15 (5 points)
When a subclass is defined, which of the following is not inherited from the super class?
Question 15 options:
All constructors
The instance variables
All constructors, except for the default constructor
The instance methods, except for the constructors
Save
Question 16 (5 points)
When a method is overridden, the determination of which method is actually called is made at which of the following times?
Question 16 options:
It depends on the program
It depends on the types of the parameters
Run time
Compile time
Save
Question 17 (5 points)
In which of the following languages can object slicing occur?
Question 17 options:
C#
C++
C
Java
Save
Question 18 (5 points)
Which of the following are permitted in a Java interface?
Question 18 options:
Abstract methods
Ordinary methods
Instance variables
Class variables
Save
Question 19 (5 points)
Which of the following are characteristics of a constructor?
Question 19 options:
It never has any parameters
The has no return type
It has no name
It always has exactly one parameter
Save
Question 20 (5 points)
Which of the following languages is not an object-oriented language?
Question 20 options:
C#
C++
Java
C
Save
Note: It is recommended that you save your response as you complete each question.Explanation / Answer
1.
Multiple inheritance of the interfaces is supported in java due to the following reasons:
· Java does not support multiple inheritance with classes due to the ambiguity of the overriding methods.
· There cannot be ambiguity in the overriding methods in case of interfaces because, the implementation of the methods is not provided in the interface.
· There can only be the declaration of methods in the interface.
Hence, the correct choice is option 3.
2.
Lifetime of the class variables is the life of the package due to the following reasons:
· The class variables have a single copy to all its instances. All the objects of the class can access the class variables.
· A class variables can be accesses by its instances till the scope of the package of the class.
Hence, the correct choice is option 2.
3.
The methods which have identical names in a same class are called as overloaded methods. Overloaded methods must have different parameters.
Hence, the correct choice is option 1.
4.
If a method is declared without its definition in a class then, that method will be an abstract method. The body of the abstract method must be defined in the derived class.
Hence, the correct choice is option 3.
5.
The lifetime of the instance variable is the life of the object due to the following reasons:
· The lifetime of the instance variable is associated with the object creation.
· Instance variables can be accessed if the object is in the memory.
Hence, the correct choice is option 4.
6.
Diamond inheritance can occur in the languages which supports any type of inheritance due to the following reasons:
· Diamond inheritance includes at least two inheritance that is: hierarchical inheritance and multiple inheritance.
Hence, the correct choice is option 4.
7.
An object-oriented language may or may not support concurrency because, there is a need of hardware support to make a concurrent program in an object-oriented language.
Hence, the correct choice is option 3 concurrency.
8.
Up casting means a type conversion of an object of a subclass to the object of the super class. This type of casting can be done implicitly and there are less chances of getting compile time error in the up casting.
Hence, the correct choice is option 1.
9.
There should be a method in the subclass with the same name and return type as of the base class method. The name, number of parameters, type of parameters, order of parameters and return type of the overridden method must be identical in the subclass.
Hence, the correct choice is option 4.
10.
An abstract class cannot be instantiated because, an abstract class is considered as incomplete class and an incomplete class should not be instantiated because, it would confront the object-oriented model of the language.
Hence, the correct choice is option 3 objects of the class can be instantiated.
11.
The correct signature for the given overriden method int method(int param) will be as same as given sinature in the problem i.e., int method(int param) because the name, return type of overriden method and number, type, and order of parameters must also be identical.
Hence, the correct choice is option 2.
12.
A variable declared as protected in java will be acccessed in the whole package but not outside the package except it will also be accessed in the subclass.
Hence, the correct choice is option 2 any method in a different package.
13.
The super() keyword refers to the immediate parent class and the parent class can also be called as super class.
Hence, the correct choice is option 1.
14.
The inner class is also called as non-static nested class. The inner class has direct access to all members, methods, private methods, variables, instance variables of both outer and inner class.
Hence, the correct choice is option 3.
15.
If the constructor of the parent class is inherited in the derived class, then there will be naming collision because the name of the constrcutor of parent class which is now also belongs to the child class has different name as compared to the child class's constructors because the constructor name should be identical to the class name.
Hence, the correct choice is option 1 all constructors.
16.
The method overrideing represents run time polymorphism in which a method or variable is resolved at run time. When a method is overriden in the subclass, then it will be determoined at run time that which method should be called whether the parent class method or the overriden method.
Hence, the correct choice is optio 3 run time.
17.
the object slicing means that an object of the derived class is copied to the object of a parent class. This can be done in C++. This concept does not naturally occur in any other language.
Hence, the correct choice is option 2 C++.
18.
A java interface is like a blue print of a class. The use of interface is to support multiple inheritance on java as a class can implement multiple interfaces. The methods declared in an interface has not body i.e., the only methods which can be used in an interface are abstract methods.
The interface will not have ordinary methods, instance and class variables. An interface can have variables which are declared as static and final.
Hence, the correct choice is option 1.
19.
The characterstics of a constructor are defined as follow:
Hence, the correct choice is option 2 that is a constructor has no return type.
20.
The C langage is an procedural language. The C laguage is not an object-oriented language. All other languages like java, C#, and C++ are object-oriented languages.
Hence, the correct choice is option 4 C language.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.