Java Programming Questions and Answers Set 25

Java Programming OOPs

Questions 241 to 250



241.
Which of the following is not a valid String Constant?
(a)
“X”
(b)
‘x’
(c)
“Hello”
(d)
“2002”
(e)
“Hello Guys”.
242.
Consider the class definition:
public class MyClass {
int x; int y;
void myprint(){
System.out.println(“x = ” +x);
System.out.println(“Y = ” +y);
}
}
Which of the following is a correct way to create an object?
(a)
MyClass mc=new MyClass();
(b)
MyClass mc;
(c)
MyClass mc=new MyClass(10,20);
(d)
MyClass mc=MyClass(10,20);
(e)
All the above.
243.
Which of the following is not true?
(a)
Every time the class is instantiated, a new copy of each of the instance variables is created
(b)
Every time the class is instantiated, a new copy of each of the class variables is created
(c)
A class has only one copy of each of its static members, which are shared by all the instances of the class
(d)
Static members are accessed without an instance of a class
(e)
An object is the instance of the class.
244.
Which of the following is not necessarily related to RMI?
(a)
Stub and skeleton
(b)
Remote interface
(c)
Graphical User Interface
(d)
Client and Server
(e)
Protocol.
245.
Which of the following is not true for a constructor?
(a)
A constructor is used to initialize an object
(b)
A default constructor takes no parameter
(c)
A constructor can be overloaded
(d)
A constructor can be declared abstract
(e)
A constructor access mutators are get() and set().
246.
Which of the following is true for method overriding?
(a)
A method in the subclass that has the same name, same arguments and same return type as a method in the super class is orverridden
(b)
An overridden method advocates for inheritance in OOP
(c)
It is not possible to access the method which is overridden in a subclass
(d)
Overridden method in java is called virtual function
(e)
Overloading method in java is called virtual function.
247.
Consider the following code:
interface A {  int a=5; int b=10;}
Which of the following is possible for the above?
(a)
class B implements A{int x;
void add(){ x= a+b; }
}
(b)
class B extends A { int x;
void add(){ x= a+b; }
}
(c)
class B implements A { int x;
void add(){ a=20; b=10; x= a+b; }
}
(d)
class B extends A{ int x;
void add(){ a=20; b=10; x= a+b; }
}
(e)
class A implements B{int x;
void add()
{              x=a+b;
}.
248.
Which of the following package is automatically imported to your program file?
(a)
java.util
(b)
java.io
(c)
java.net
(d)
java.lang
(e)
java.math.
249.
Which of the following is not true for a java thread?
(a)
The run method calls start method
(b)
The start method calls run method
(c)
Runnable interface contains only run method
(d)
The run method is overridden to contain the functionality of the application
(e)
Once we use the stop() method on a thread, we cannot use the start() method.
250.
Which is not a valid operator in Java?
(a)
<> 
(b)
!=
(c)
=>
(d)
<=
(e)
+=.

Answers


241.
Answer : (b)
Reason  :       ‘x’ is not a valid string constant.
242.
Answer : (a)
Reason  :       correct way to create an object MyClass mc=new MyClass();
243.
Answer : (b)
Reason  :       Every time the class is instantiated, a new copy of each of the class variables is created
244.
Answer : (c)
Reason  :       GUI  not necessarily related to RMI
245.
Answer : (d)
Reason  :       A constructor can be declared abstract
246.
Answer : (a)
Reason  :       A method in the subclass that has the same name, same arguments and same return type as a method in the super class is orverridden
247.
Answer : (a)
Reason  :       A is the right choice of declaration.
248.
Answer : (d)
Reason  :       the java.lang package is automatically imported to your program file
249.
Answer : (a)
Reason  :       The run method doesnot call start method.
250.
Answer : (a)
Reason  :       <> is not a valid operator in java.



<< Prev   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22  

 23   24   25   26   27   28   29   30  Next >>


1 comment :