Java Programming OOPs
Questions 211 to 220
211.
|
Which of
the following is/are valid comment(s) in java?
|
||||||||||
212.
|
What is
the correct signature of the main method?
|
||||||||||
213.
|
Which of
the following is not a valid statement?
|
||||||||||
214.
|
What is
the correct order of defining a Class?
1. The name of the class's parent (super
class), if any, preceded by the keyword extends. A class can only extend
(subclass) one parent.
2. The
class name, with the initial letter capitalized by convention.
3. Modifiers
such as public, private, and a number of others that you will encounter
later.
4. The
class body, surrounded by braces, {}.
5. A comma-separated list of interfaces
implemented by the class, if any, preceded by the keyword implements. A class
can implement more than one interface.
|
||||||||||
215.
|
public class PassPrimitiveByValue {
public
static void main(String[] args) {
int
x = 3;
//invoke
passMethod() with x as argument
passMethod(x);
//
print x to see if its value has changed
System.out.println("After
invoking passMethod, x = " + x);
}
//
change parameter in passMethod()
public
static void passMethod(int p) {
p =
10;
}
}
What is
the output of the above program?
|
||||||||||
216.
|
What is the output of the following code?
IdentifyMyParts
a = new IdentifyMyParts();
IdentifyMyParts
b = new IdentifyMyParts();
a.y
= 5;
b.y
= 6;
IdentifyMyParts.x
= 1;
b.x
= 2;
System.out.println("a.y
= " + a.y);
System.out.println("b.y
= " + b.y);
System.out.println("IdentifyMyParts.x
= " + a.x);
System.out.println("b.x = " + b.x);
|
||||||||||
217.
|
Which of
the following is legal valid variable name?
|
||||||||||
218.
|
What is
the bit size of int in java?
|
||||||||||
219.
|
Which one
of these is a valid constructor declaration for the class named student?
|
||||||||||
220.
|
Which
access specifiers should be implemented in a class for all interface methods?
I. Private.
II. Public.
III. Protected.
|
Answers
211.
|
Answer : (c)
Reason: The Java programming language supports three
kinds of comments:
/* text */
The compiler
ignores everything from /* to */.
/** documentation
*/
This indicates a
documentation comment (doc comment, for short). The compiler ignores this kind
of comment, just like it ignores comments that use /* and */.
// text
The compiler
ignores everything from // to the end of the line.
|
212.
|
Answer : (b)
Reason: The correct signature is public static void
main(String[] args)
|
213.
|
Answer : (d)
Reason: Class methods cannot access instance
variables or instance methods directly—they must use an object reference.
|
214.
|
Answer : (c)
Reason: class declarations can include these
components, in order:
1. Modifiers such as public, private, and a
number of others that you will encounter later.
2. The class name, with the initial letter
capitalized by convention.
3. The name of the class's parent
(superclass), if any, preceded by the keyword extends. A class can only
extend (subclass) one parent.
4. A comma-separated list of interfaces
implemented by the class, if any, preceded by the keyword implements. A class
can implement more than one interface.
The class body,
surrounded by braces, {}.
|
215.
|
Answer : (b)
Reason: Primitive arguments, such as an int or a
double, are passed into methods by value. This means that any changes to the
values of the parameters exist only within the scope of the method. When the
method returns, the parameters are gone and any changes to them are lost.So
the output is 3 only.
|
216.
|
Answer : (a)
Reason: Remaining all are contradictory.
|
217.
|
Answer : (d)
Reason: Can only Start with a Letter, Underscore (_)
, or Dollar Sign ($).After the first letter Name can include any letter or
Number but cannot include Symbols such as %, @, * and so on.
|
218.
|
Answer : (c)
Reason: The bit size of int is 32.
|
219.
|
Answer : (a)
Reason: A constructor cannot specify any return
type, not even void. A constructor cannot be final, static or abstract.
|
220.
|
Answer : (b)
Reason: Interfaces are abstraction of functionality
that can be implemented in more than one way when required. The abstraction
must be made available as public for the use by other parts of the program.
|
Q 211. Which of the following is/are valid comment(s) in java?
ReplyDeleteIt should be "Which of the following is/are INVALID comment(s) in java?"
This is a great article.I am y much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.
ReplyDeletejava examples
thank you.
ReplyDeletejava tutorial
java tutorial
Nice article.you have shared nice post.
ReplyDeletevisit java batch processing example
click here
good pick up lines
ReplyDeleteSign Up into EnjoyXoxo, It is the clever and good pick up lines. Here you can find new friends and create new partnerships. This is a funny pick up lines platform there you can fun with friends nearby or far.
contact address: (31) 641-979389
support@enjoyxoxo.com
Kruitberg 5634, 1104 CA, Amsterdam Zuidoost. Netherlands
Διαβάστε περισσότερα
ReplyDeleteΚατασκευή ιστοσελίδων, eshop και προώθηση - Η μεγαλύτερη λίστα επιτυχημένων ιστοσελίδων είναι εδώ. Ειδικευόμαστε στον σχεδιασμό και την υποστήριξη όλων των τύπων website.
do you make money from a blog
ReplyDeleteCheck out our detailed guide on how to make money blogging. This article will describe the way to start a blog through a step by step procedure.
Vitiligo Treatment
ReplyDeleteMONOBENZONE Benoquin Vitiligo Treatment with Benoquik to Get results within 4 weeks with Benoquik 20% Cream High Quality, Fast Delivery in USA Benoquin Redues patches, makes skin natural glowing and helps to achieve uniform depigmentation, Skin Lighting agent,"
Custom sunroof installation
ReplyDeletewe offer a wide range of new installation sunroofs, including our in-built power sunroofs which feature rear vent, one-touch open and close, key-off auto close, and integrated sun-shades that retract inside the roof of your car and can be custom made to suit your vehicle.
App developers in Bangalore
ReplyDeleteAs one of the best mobile app development companies in Bangalore, we work with a wide range of brands in all industries. We will give an awesome idea and concept that will help your company reach the next level. Our app developers in Bangalore utilize interactive mobile layouts, pitch perfect development, and appropriate call-to-action buttons.
Nice blog, thanks for sharing this blog. Benoquin cream is applied to de-pigment the skin as a vitiligo treatment , Vitligo is a skin condition of irregular patches on skin, covering about 50% of the body surface, lose colour and become whitened.
ReplyDeleteIt's really nice to read and very informative. So much thanks for the sharing.
ReplyDelete
ReplyDeleteVery informative blog! Thanks for sharing.