Font size
WorksheetsCS8392 - Object Oriented Programming - Unit 1
Total questions: 63
Worksheet time: 36mins
A programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
(from Greek meaning “many forms”) is the quality that allows one interface to access a general class of actions.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
Is the process by which one object can acquire the properties of another object.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
Select all the given characteristic of OOP
Data structures are designed such that they characterize the objects.
C input/output is based on library and the processes are carried out by including functions.
Programs are divided into what are known as objects.
Emphasis is on data rather than procedure
C++ is procedure oriented programming & C is object oriented programming.
True
False
Trulse
I don't know
Which of the following option leads to the portability and security of Java?
Bytecode is executed by JVM
The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
Where an object of a class get stored?
Heap
Stack
Disk
File
Java uses two stage system for program execution. They are
Compiler and instruction
Compiler and interpreter
Copy and compiler
None
Garbage collection in Java is
Unused package in a program automatically gets deleted.
Memory occupied by objects with no reference is automatically reclaimed for deletion.
Java deletes all unused java files on the system.
The JVM cleans output of Java program.
Java compiled source code programs have extension
.java
. source
.class
. compile
Which of the following is smallest integer data type ?
long
int
byte
short
Byte variables are declared by use of the ____________ keyword (Using Primitive Data Type).
byte
Byte
Bytes
bytes
Default value of character data type in Java Programming is ___________________.
null
undefine
0
"\u0000'
________ is wrapping of data into a single unit called class.
Abstraction
Polymorphism
Encapsulation
Inheritance
__________ refers to the act of representing essential details.
Polymorphism
Abstraction
Inheritance
Encapsulation
__________ is the process in which objects of one class can link and share some common properties from the objects of another class.
Abstraction
Inheritance
Polymorphism
Encapsulation
__________ is the process of using a function for more than one purpose. It allows the use of different internal structures of the object by keeping the same external interface.
Inheritance
Polymorphism
Abstraction
Encapsulation
In this process the function call is linked to the function signature at runtime.
Dynamic Binding
Static Binding
This is the logical link from caller program to the function and is established by using function name in the caller program
Dynamic Binding
Static Binding
Choose Object oriented programming languages from the following.
C
Java
BASIC
Small Talk
Which of the following adopts top down approach?
Object Oriented Programming
Procedural Programming
An _________ is an instance or of a copy of a class.
Class
Object
Attribute
A ________ is blue print that defines certain characteristics and behavior. It is simply a representation of different types of objects.
Class
Object
Attribute
Characteristics
Which of this keyword must be used to inherit a class?
super
this
extends
extent
A class member declared protected becomes a member of subclass of which type?
public member
private member
protected member
static member
class A
{
int i;
void display()
{
System.out.println(i);
}
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class inheritance_demo
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
0
1
2
Compilation Error
What will be the output of the following Java program?
class A
{
int i;
}
class B extends A
{
int j;
void display()
{
super.i = j + 1;
System.out.println(j + " " + i);
}
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
2 2
3 3
2 3
3 2
Using which of the following, multiple inheritance in Java can be implemented?
Interfaces
Multithreading
Protected methods
Private methods
If super class and subclass have same variable name, which keyword should be used to use super class?
super
this
upper
classname
In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
Protected
Private
Public
Static
If class B is subclassed from class A then which is the correct syntax
class B:A{}
class B extends A{}
class B extends class A{}
class B implements A{}
Which inheritance in java programming is not supported
Multiple inheritance using classes
Multiple inheritance using interfaces
Multilevel inheritance
Single inheritance
Order of execution of constructors in Java Inheritance is
Base to derived class
Derived to base class
Random order
none
Attributes of an object are also known as
methods
properties
classes
functions
Programming statements written in a high-level programming language are called ____.
Byte Code
Source Code
executable code
destination code
Which of the following is not a primitive data type of JAVA?
int
char
String
float
Java is a platform independent programming language because
It is written almost similar to English language
Java compiler translates the source code directly to the machine level language.
It follows the concept of “write once and compile everywhere”.
It compiles to an intermediate code targeting a virtual machine, which can be interpreted by an interpreter for a given OS.
Which of the following features are not common in both java and c++?
The class declaration
The access modifiers
The Encapsulation of data and methods
multiple inheritance from class
What is the output of following program?
class incr
{
public static void main(String args[])
{
int i=3;
System.out.println( ++i * 5);
}
}
(a)
Which of the following can not be used as correct variable name(identifier) in JAVA?
malloc
final
calloc
string
Attributes of an object are also known as
methods
properties
classes
functions
+ getEndDate
+ setOverdraft
are examples of what in OOP?
Classes
Objects
Attributes / Properties
Methods
+ getAccountNumber
+ addInterest
are examples of what in OOP?
Classes
Objects
Attributes / Properties
Methods
Mortgage, Current and Account
are examples of what in OOP?
Classes
Objects
Attributes / Properties
Methods
You can make changes to an object with
methods
attributes
modifiers
parameters
A method is...
A way of calculating things in Java
A strategy for programming
A predefined set of instructions in a class
A way to sore details in a class
Which of the following is the correct main() method signature in Java?
public static void main (String [] args)
public static void Main (String [] args)
public static void main (string [] args)
public static void main (String args)
Which of the following is a comment in the Java language?
/ comment /
//comment
/ comment */
<-- comment -->
Which of the following is a valid variable declaration in Java?
int 1myInteger = 0;
int int = 0;
Int my Integer = 0;
int myInteger = 0;
Which of this command does not have errors?
System.out.print("Hello World")
System.out.print(Hello World);
System.out.Print("Hello World);
System.out.print("Hello World");
What will be output of below program?
public class Test {
public static void main(String[] args) {
int x = 10*20-20;
System.out.println(x);
}
}
Runtime Error
Prints 180
Prints 0
None of the above
What is the output for the following statement:
System.out.print("1"+"1");
11
2
Error Message
Indicate the actual output of the statements below:
int thisYear = 2020;
System.out.println("The current year is "+thisYear);
The current year is thisYear
The current year is 2020
No output; an error exists
The current year is
Which of the following is used as a terminator in Java programming?
)
;
.
>
What is the problem with this code?
Line 1: String myName = "Mary Jacobson";
Line 2: System.out.println ("My name is " + myname);
Line 2: should be System.out.println ("My name is myName");
Line 2: should be System.out.println ("My name is "+ myName);
Line 2: should be System.out.display("My name is " + myname);
There is no problem with the code
int x= 10;
int y = 20;
int z = x + y;
System.out.println(z);
Guess the output.
1020
10 20
30
"10 20"
What is the job of a Java class's fields?
Used for communication with an object of this class type
Used for calculations when an object is constructed
Allows for import statements in this class
Store the state of an object of this class type
How many constructors does this Java class have?
0
1
2
3
What is the return type of Constructors?
int
float
void
none of the mentioned
Which of this statement is incorrect?
All object of a class are allotted memory for the all the variables defined in the class
If a function is defined public it can be accessed by object of other class by inheritance.
main() method must be made public
All object of a class are allotted memory for the methods defined in the class
Write method header to Return a square root of a number
public static void double sqrt(value)
public static void double sqrt(double value)
public static double sqrt(value)
public static double sqrt(double value)
The body of a method definition is contained within a set of ______________.
parentheses
rectangle brackets
curly braces
angle brackets
