Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

please help !!!urgent

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys
please give the correct answer and explain the answer
ques 1 which method are legal method names
- public abstract method();
x public abstract void method();
- public void abstract Method();
- public void method() {abstract;/}
- public abstract void method() {/}

ques 2
which are valid native method declaration
x public native void myMethod()
- public native myMethod()
- public void myMethod(native)
ques 3
given below is valid or not
if (i-- \> 0) valid
"\>" what mean
ques 4
String s = "message";
Frame f = new Frame();
f.add(btn);
btn.addActionListener(
new ActionListener() {
void ActionPerformed() {System.out.println(s);}
}

String str = "Good";
String other = " "+"morning"+",";
str.append(other);
str.toUpperCase();
str += "guys";

)
f.pack();
f.setVisible();
 
bala_chocos
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question 5
What are legal operations on s?
String s = "something";
A.s >>= "ok";
B.char c = s[4];
C.s += 3;
D.s -= "thing";
E.s = s + "good";
question 6
What is the output of the following
StringBuffer sb1 = new StringBuffer("Amit");
StringBuffer sb2= new StringBuffer("Amit");
String ss1 = "Amit";
System.out.println(sb1==sb2);
System.out.println(sb1.equals(sb2));
System.out.println(sb1.equals(ss1));
System.out.println("Poddar".substring(3));
The answer given is false, false, false, "dar".
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi bala,
Here is my answers,
ques 1 which method are legal method names
- public abstract method(); // False - no return type
x public abstract void method(); // True
- public void abstract Method(); // False abstract after void
- public void method() {abstract;/} // False
- public abstract void method() {/} // False

ques 2
which are valid native method declaration
x public native void myMethod() // True
- public native myMethod() // False
- public void myMethod(native) // False
ques 4
String s = "message";
Frame f = new Frame();
f.add(btn);
btn.addActionListener(
new ActionListener() {
void ActionPerformed() {System.out.println(s);} }
// U can't Use button btn before declaration
String str = "Good";
String other = " "+"morning"+",";
str.append(other); // String has NO append Method
str.toUpperCase();
str += "guys";
)
f.pack();
f.setVisible();
What are legal operations on s?
String s = "something";
A. s >>= "ok";
B. char c = s[4];
C. s += 3; // True
D. s -= "thing";
E. s = s + "good"; // True

Aruna
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
The answer to the third question :
ques 3
given below is valid or not
if (i-- \> 0) valid
"\>" what mean
Ans : Invalid.
"\>" does not mean anything. Java supports a few escape sequences for denoting special characters.
some of them are listed below :
'\n' for newline
'\r' for Return
'\t' for tab
'\b' for backspace
'\f' for formfeed
'\'' for Single Quote
'\"' for Double Quote
'\\' for Back Slash

am i right?

Thanks,
Sunitha. S
 
Where does a nanny get ground to air missles? Protect this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic