What is the output of the following code: class eq { public static void main(String args[]) {
String s1 = “Hello”; String s2 = new String(s1); [Link](s1==s2); } }
False
The copy constructors can be used to ________
Copy an object so that it can be passed to a function
Which of these is not a correct statement?
Abstract class can be initiated by new operator
What is an abstraction in object-oriented programming?
Hiding the implementation and showing only the features
Which constructor will be called from the object created in the below C++ code? class A {
int i; A() { i=0; cout<<i; } A(int x=0) { i=x; cout<<I; } }; A obj1;
Compile time error
If static data members have to be used inside a class, those member functions
Must be static member functions
Which of these access specifiers can be used for an interface?
Public
Which of these is not abstract?
Thread
A protected member can be accessed in,
a non-subclass of different package
Which among the following is wrong syntax related to static data members?
className : dataType -> memberName;
Which of these is correct way of inheriting class A by class B?
class B extends A {}
A class member declared protected becomes a member of a subclass of which type?
private member
An abstract class in Java usually contains one or more abstract
Methods
What is the output of the below Java code with an abstract class and inner class? public
abstract class AbstractClassTest6 { class Anonymous { int a=5; } public static void
main(String args[]) { [Link]("Inner class is present.."); } }
Inner class is present..
If a class inheriting an abstract class does not define all of its function then it will be known
as?
Abstract
Which of these can be used to fully abstract a class from its implementation?
Interfaces
Which is the correct declaration to implement two interfaces?
class A implements B, C {}
Which is the correct syntax of inheritance?
class derived_classname : access base_classname{ /*define class body*/ };
Which among the following is correct for the class defined below?
Program runs and all objects are create
An abstract data typically comprises a …………… and a set of ……………... respectively.
Data representation, operations
How to access data members of a class?
Dot or arrow as required
What is the output of the below Java program with an abstract class? abstract class
MathLibrary { static final float PI = 3.1415f; } public class AbstractClassTesting3 { public static
void main(String[] args) { [Link]([Link]); } }
3.1415
Which of the following is not true about polymorphism?
Increases overhead of function definition always
What happens when an object is passed by reference?
Destructor is not called
Which of these packages contains abstract keyword?
[Link]
How many types of access specifiers are provided in OOP (C++)?
The correct order of the declarations in a Java program is-
Package declaration, import statement, class declaration
In which access should a constructor be defined, so that object of the class can be created in
any function?
Public
Choose correct statements about an Abstract class in Java?
All the above
In multilevel inheritance, which is the most significant feature of OOP used?
Code reusability
Which of these keywords is used to prevent content of a variable from being modified?
Final
When an overridden method is called from within a subclass, it will always refer to the
version of that method defined by the
Subclass
Which of the following is the correct way of implementing an interface salary by class
manager?
class manager implements salary {}
Choose a correct statement about abstract classes?
All the above
What is the correct way to implement an interface? Example, ‘Operation’ interface
implements ‘Add’ class.
class Add implements Operation{}
Which among the following is the correct syntax to access static data member without using
member function?
className :: staticDataMember;
Which keyword should be used to declare static variables?
Static
You read the following statement in a Java program that compiles and executes.
[Link](depth); What can you say for sure?
dive must be a method.
Can we declare an interface as final?
No
Which of these keywords is used to define interfaces in Java?
interface (small letter i)
Which is the correct syntax for declaring static data member?
static dataType memberName;
Which among the following can show polymorphism?
Overloading <<
Which type of members can’t be accessed in derived classes of a base class?
Private
Mark the incorrect statement from the following:
In java language error processing is built into the language
What does an interface contain?
Method declaration
The class whose properties are inherited is known as superclass.
TRUE
Which access specifier is usually used for data members of a class?
Private
Which among the following, for a pure OOP language, is true?
The language must follow all the rules of OOP
The language must follow all the rules of OOP
main()
In object-oriented programming, the process by which one object acquires the properties of
another object is called
Inheritance
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{ };
};
Single level inheritance is used, with both enclosing and nested classes
What is the output of the following Java code?
class Person
{
private int age;
private Person()
{
age = 24;
}
}
public class Test
{
public static void main(String[] args)
{
Person p = new Person();
[Link]([Link]);
}
}
Compilation error
Find the order of execution of constructors in Java Inheritance in the following bellow -
class Animal{
public Animal(){
[Link]("Base Constructor");
}
}
class Cat extends Animal{
public Cat(){
[Link]("Derived Constructor");
}
}
public class Program {
public static void main(String[] args) {
Cat c = new Cat();
}
}
Base to derived class
Find the correct answer from the following two program -
The derived class inherits all the members and methods
Check the program and find out if it will run properly?
class A
{
void msg()
{
[Link]("Hello Java");
}
}
class B
{
void msg()
{
[Link]("Welcome you");
}
}
class C extends A, B
{
public static void main(String args[])
{
C obj = new C();
[Link]();//Now which msg() method would be called?
}
}
Got compile time error