JAVA
Question 1 |
In Java, when we implement an interface method, it must be declared as:
Private | |
Protected | |
Public | |
Friend |
Question 2 |
Which one of the following is correct?
Java applets can not be written in any programming language | |
An applet is not a small program | |
An applet can be run on its own | |
Applets are embedded in another applications |
Question 3 |
Which of the following statements is/are TRUE regarding JAVA ?
(a) Constants that cannot be changed are declared using the ‘static’ keyword.
(b) A class can only inherit one class but can implement multiple interfaces.
Only (a) is TRUE. | |
Only (b) is TRUE. | |
Both (a) and (b) are TRUE. | |
Neither (a) nor (b) are TRUE. |
Question 3 Explanation:
FALSE: Constants that cannot be changed are declared using the ‘static’ keyword.
TRUE: A class can only inherit one class but can implement multiple interfaces.
TRUE: A class can only inherit one class but can implement multiple interfaces.
Question 4 |
Which of the following features is the best to support JAVA application development distributed across a network of Java Virtual machines?
Remove Method Invocation (RMI) | |
Remote Procedure Calls (RPC) | |
Multicast sockets | |
Remote Method Invocation (RMI) or Remote Procedure Calls (RPC) |
Question 5 |
Which of this process occur automatically by JAVA run time system?
Serialization | |
Garbage collection | |
File Filtering | |
All the given options |
Question 5 Explanation:
Serialization and deserialization occur automatically by java runtime system, Garbage collection also occur automatically but is done by CPU or the operating system not by the java runtime system
Question 6 |
The ‘new’ operator in JAVA
Returns a pointer to a variable
| |
Creates a variable called new | |
Obtains memory for a new variable | |
Tells how much memory is available |
Question 6 Explanation:
“new” operator in java is used to create a new object. And an object is nothing but an instance of a class. Some memory is allocated to each object for its execution. Hence option(C) is the correct answer.
Question 7 |
“this” keyword in JAVA is used to
Refer to current class object | |
Refer to static method of the class
| |
Refer to parent class object | |
Refer to static variable of the class |
Question 7 Explanation:
“this” is a reference variable that refers to the current object of the class.
Question 8 |
Java Virtual Machine (JVM) is used to execute architectural neutral byte code. Which of the following is needed by the JVM for execution of Java Code?
Class loader only | |
Class loader and Java Interpreter | |
Class loader, Java Interpreter and API | |
Java Interpreter only |
Question 9 |
If a constructor 'Date' is declared explicitly and has to be defined outside the class, which of the following is correct?
Date::Date(int dd) {/*...*/} | |
explicit Date::Date(int dd) {/*...*/} | |
Such a constructor cannot be defined | |
Constructor always has to be defined inside the class |
Question 9 Explanation:
Defining a Constructor Outside of the Class :Although the constructor can be defined outside of the class, it must be declared inside class. Use the scope resolution operator while defining a constructor outside of the class.
class class_name {
public:
class_name();
};
// Defining a Constructor Outside of the Class by using :: operator
class_name::class_name()
{
}
class class_name {
public:
class_name();
};
// Defining a Constructor Outside of the Class by using :: operator
class_name::class_name()
{
}