Originally posted by Shubhangi A. Patkar:
Vidya, Gautam,
This is what the documentation says:
That means that even if there is nothing to trim, a new string is created and returned.
Correct me if I got this wrong...
Shubhangi
[This message has been edited by Shubhangi A. Patkar (edited November 28, 2000).]
Originally posted by shree vijay:
Hi,
It worked! thanks. How should i improve my coding style?
Would you clarify?
Thanks,
Shree
Originally posted by lucy hu:
why
If s=null, Float.valueOf(s) will throw NullPointerException
If s=null, Integer.parseInt(s) will throw NumberFormatException
Originally posted by shree vijay:
Hi,
Consider the following program:
/* Creating a purchase order screen */
import java.awt.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
class POFrame extends JFrame
{
// constructor
public POFrame()
{
super("Purchase Order");
Panel leftPanel;
Panel rightPanel;
Panel topPanel;
Panel paymentPanel;
Panel submitCancelPanel;
setBounds(50,50,600,500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().setLayout(new GridLayout(3,0));
leftPanel=new Panel();
rightPanel=new Panel();
topPanel=new Panel();
paymentPanel=new Panel();
submitCancelPanel=new Panel();
// Filling the TopPanel
leftPanel.setLayout(new GridLayout(4,1));
leftPanel.add(new Label("Date"));
Date today = new Date();
DateFormat df = getDateInstanceDateFormat.LONG,Locale.US);//1
String prntDate = df.format(today);
TextField dateText = new TextField();
dateText.setText(prntDate);
leftPanel.add(dateText);
leftPanel.add(new Label("ITEM CATEGORY"));
Choice item_category = new Choice();
item_category.addItem("Hardware");
item_category.addItem("Software");
leftPanel.add(item_category);
rightPanel.setLayout(new GridLayout(4,1));
rightPanel.add(new Label("ITEM DESCRIPTION"));
rightPanel.add(new TextArea());
rightPanel.add(new Label("ITEM COMPONENT"));
java.awt.List compList = new java.awt.List(3,false);
compList.add("Network");
compList.add("CDROM");
compList.add("Desktop");
rightPanel.add(compList);
topPanel.setLayout(new GridLayout(1,2));
topPanel.add(leftPanel);
topPanel.add(rightPanel);
paymentPanel.setLayout(new GridLayout(4,1));
paymentPanel.add(new Label("PAYMENT METHOD"));
CheckboxGroup cbg=new CheckboxGroup();
Checkbox cbx1=new Checkbox("Visa",false,cbg);
Checkbox cbx2=new Checkbox("MasterCard",false,cbg);
Checkbox cbx3=new Checkbox("American Express",false,cbg);
paymentPanel.add(cbx1);
paymentPanel.add(cbx2);
paymentPanel.add(cbx3);
// Filling the submitCancelPanel
// add Buttons
Button CancelButton = new Button("Cancel");
Button SubmitButton = new Button("Submit");
CancelButton.setBackground(Color.blue);
SubmitButton.setBackground(Color.red);
submitCancelPanel.add(CancelButton);
submitCancelPanel.add(SubmitButton);
getContentPane().add(topPanel);
getContentPane().add(paymentPanel);
getContentPane().add(submitCancelPanel);
setVisible(true);
}
}
In the getDateInstance() call in line marked // 1
i am getting a cannot resolve symbol error. I checked the syntax and the import statements , but couldn't find the bug
... Any help?
Originally posted by Mamta Jha:
I have a doubt regarding marking in real exam.If a ques has more than 1 correct answer and I miss one of the answers or 1 of the ans is wrong ,do I get 0 for that ques.
Plz clear my doubt.
Thanks,
Mamta
Originally posted by Mamta Jha:
hi everybody,
My doubt is
1.String s=null;
System.out.println(s.length());
should throw nullpointer exception,but it shows 0.why?
2.for(int i=0; i<N; i++)>
String tmp = "test"; //why this shows compilation error as variable redeclaration
I'll be thankful,if anybody could answer these ques
Thanks,
Mamta
Originally posted by John Wetherbie:
No, don't think this.A1.i will work. (At least it doesn't for my version of the JDK. :-))
When you instantiate A you don't automatically get an A1. You need to explicitly create an A1. If A had a ctor then that might be a goob place to do it.
Given the example code, here is a way to set the i var of A1:
// inside class B
B(int i,
int j)
{
A.A1 a1 = new A.A1(); // can also use A1 a1 = new A1
this.j = j;
}
The next question that arises is how to access this A1 instance. It would seem that without A or B having a member variable of class A1 it would go out of scope.
Help, anyone!?
John
Originally posted by Santhosh Kumar:
Hi All,
Can we use calculator in the exam? Is its allowed, it will be very easy for binary and other conversions.
Originally posted by Samir Parikh:
Pl. see following code..
interface I {
int i = 1;
int ii = Sam1.out("ii",2);
}
interface J extends I {
int j = Sam1.out("j",3);
int jj = Sam1.out("jj",4);
}
interface K extends J {
int k = Sam1.out("k",5);
}
public class Sam1{
public static void main(String args[]){
System.out.println(J.i);
System.out.println(K.j);
}
static int out(String s,int i){
System.out.println(s + " = " + i);
return i;
}
}
Now the output of this code is ..
1
j=3
jj=4
3
Why it does not display ii=2 ?
Originally posted by Shubhangi A. Patkar:
Could any one please shed a light on this?
Are there any questions on the following topics or are these to be studied as a pre requisite for other topics:
1. awt components: do questions on these come(as in constructor or methods or questions are more on the events that these generate?)
2. applets: esp about the parameters taken, tags to be put in html files etc.
3. jar/ javadoc utilities
I can't find a refernce to these in any of the objectives(awt obejctive is does say component and container but i am slightly confused), but mocks seem to carry questions on these. I need to know if a general idea is enough or do i need to cram about this also?
TIA,
Shubhangi
Originally posted by Bin Zhao:
TRUE or FALSE
Only Frames can contain menu bars or pull-down menus.
I think it is true.
But a mock exam's anwser is false.
Can anyone clear this?
Originally posted by lakshmi nair:
Just wondering, is Void a wrapper class? Its not specified explicitly as for all other wrapper classes in the API.