Java Programming OOPs
Questions 21 to 30
21.
|
What is
byte code in the context of Java?
(a) The type of code generated by a Java
compiler.
(b) The type of code generated by a Java
Virtual Machine.
(c) It is another name for a Java source
file.
(d) It is the code written within the
instance methods of a class.
(e) It is another name for comments
written within a program.
|
22.
|
What is
garbage collection in the context of Java?
(a) The operating system periodically deletes
all the java files available on the system.
(b) Any package imported in a program and not
used is automatically deleted.
(c) When all references to an object are gone,
the memory used by the object is automatically reclaimed.
(d) The JVM checks the output of any Java
program and deletes anything that doesn't make sense.
(e) Janitors working for Sun Micro Systems are
required to throw away any Microsoft documentation found in the employees'
offices.
|
23.
|
You read
the following statement in a Java program that compiles and executes.
submarine.dive(depth);
What can
you say for sure?
(a) depth must be an int
(b) dive must be a method.
(c) dive must be the name of an instance field.
(d) submarine must be the name of a class
(e) submarine must be a method.
|
24.
|
The java
run time system automatically calls this method while garbage collection.
(a) finalizer() (b) finalize() (c) finally()
(d) finalized() (e) none of the above.
|
25.
|
The
correct order of the declarations in a Java program is,
(a) Package declaration, import statement, class declaration
(b) Import statement, package declaration,
class declaration
(c) Import statement, class declaration,
package declaration
(d) Class declaration, import statement,
package declaration
(e) Class declaration, package declaration,
import statement.
|
26.
|
An
overloaded method consists of,
(a) The same method name with different types
of parameters
(b) The same method name with different number
of parameters
(c) The same method name and same number and
type of parameters with different return type
(d) Both (a) and (b) above
(e) (a), (b) and (c) above.
|
27.
|
A
protected member can be accessed in,
(a) a subclass of the same package (b)
a non-subclass of the same package
(c) a non-subclass of different package (d) a
subclass of different package
(e) the same class.
Which is
the false option?
|
28.
|
What is
the output of the following code:
class eq
{
public static void
main(String args[])
{
String s1 = “Hello”;
String s2 = new
String(s1);
System.out.println(s1==s2);
}
}
(a) true (b) false (c) 0 (d) 1 (e) Hello.
|
29.
|
All
exception types are subclasses of the built-in class
(a) Exception (b) RuntimeException (c)
Error
(d) Throwable (e) None of the above.
|
30.
|
When an
overridden method is called from within a subclass, it will always refer to the version of that method defined
by the
(a) Super class
(b) Subclass
(c) Compiler will choose randomly
(d) Interpreter will choose randomly
(e) None of the abvove.
|
Answers
21.
|
Answer : (a)
Reason: Java compiler compiles the source code file
and converts it into a class file, which consists of byte code.
|
22.
|
Answer : (c)
Reason: Garbage collection in the context of Java is when all references
to an object are gone, the memory used by the object is automatically
reclaimed.
|
23.
|
Answer : (b)
Reason: The other choices can be allowed, but not
‘must’
|
24.
|
Answer : (b)
Reason: ‘finalize()’ method is automatically called
by the java compiler before destroying the object to free any resources.
|
25.
|
Answer : (a)
Reason: First the package name is defined. Then the
import statements if any. And then the class declaration goes on.
|
26.
|
Answer : (d)
Reason: Even though the return type varies, it will
not be considered for overloading concept. Only method name and parameters
are considered.
|
27.
|
Answer : (c)
Reason: A protected member cannot be accessed in
non-subclasses of different packages.
|
28.
|
Answer : (b)
Reason: Since , the contents of the two String
objects are identical, but they are distinct objects.
|
29.
|
Answer : (d)
Reason: Throwable is the super class of all the
exception classes.
|
30.
|
Answer : (b)
Reason: The compiler will always selects the version
of the method in subclass. superclass method can be called by explicitly
assigning super reference.
|
SUPERB. KEEP IT UP
ReplyDeleteit very easy to know.
DeleteThis comment has been removed by the author.
ReplyDeletewooow!
ReplyDeleteI really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in LIFERAY, kindly contact us http://www.maxmunus.com/contact
ReplyDeleteMaxMunus Offer World Class Virtual Instructor led training on LIFERAY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us.
Saurabh Srivastava
MaxMunus
E-mail: saurabh@maxmunus.com
Skype id: saurabhmaxmunus
Ph:+91 8553576305 / 080 - 41103383
http://www.maxmunus.com/
thank you.
ReplyDeletejava tutorial
java tutorial
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteVidyasthali Group of Institutions was founded by an eminent group of academics and industry leaders who are masters of the top significant achievements and accomplishments. Vidyasthali is a reputed B-school in Jaipur.
vidyasthali institute of technology science&managment
best techonology science and management institute in jaipur
courses in vidyasthali group of institute
no 1 technology science & management college in jaipur
best management
vitsm
vidyasthali institute of technology science and managment
techonlogy science&management college near me,
best technology
best management
VITSM teaching staff
vitsm courses
top science college
best science colleges in jaipur
best science college in jaipur
vitsm fees structure
vitsm fee structure
vitsm result
Great post! you explore this topic in very effective way I want to appreciate your work, thank you for sharing such a useful information. Artificial Intelligence Course in Muscat | Robotic And Coding For Kids in Muscat | Digital Marketing Training in Muscat | SEO Services in Muscat
ReplyDelete
ReplyDeletevery nice blogs!!! i have to learning for lot of information for this sites.Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing
Commutative Property of Addition
Vertical Angles
Lesson on Greater than Sign
edublack boards
Hi, Thank you for this informative blog, I have just started to learn java course and this blog is really informative for me. Thank you for this blog!
ReplyDeleteThank you for sharing this amazing post. Looking forward to reading more.
ReplyDeleteVisit us: Java Training
Visit us: Java Course