Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

bani kaali

Ranch Hand
+ Follow
since May 05, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by bani kaali

Hi,
I am new to Jcreator IDE and I am not able to set main method argumets. I know I can pass arugments to main methold by performing on the following options. I did try both options listed below,But I dont know where I am going wrong, I am still unable to pass arugment and when I print args.length it still says args =0!!
Option One
1. Choose Options from the Configure menu.
2. Select JDK Tools, select Run Application from the pull down list, Edit.
3. The Tool Configurations dialog box will be displayed.
4. Enable the checkbox ''Prompt for main method arguments"
Option Two
1. Open or Create a project.
2. Select Runtime Configurations from the build menu.
3. Select new or edit.
4. The Set RunTime Configuration dialog will popup where you can fill in the arguments.
5. Start the runtime item via the pull down menu next to the execute project-button.
I have written a simple program to check whether a data packet is valid. The program expects a (packet) argument >=2. The first entry in args[0], specifies the total length of the packet,including the first word in the count (assumption args[0]>=2).
The last word in the packet, args[args[0]-1], is a simple checksum that is computed by adding up all of the values in the previous array locations, including the length field, but not including the checksum field.
For example, here is one valid packet:
[ 10 1 2 1 2 3 4 3 4 30 ]
The smallest valid packet is:
[ 2, 2 ]
My program is compiling fine and I know it will work but I am unable to pass arguments. Can any one please take the trouble to tell me where I am going wrong??
Thanks
bani
Hi Mohan,
I would appreciate if you can email the SCJP part of the notes.
My email id is bannikali@yahoo.com
Thanks again,
bani
Hi,
I am new to this group and I am planning to take
Introduction to Oracle9i: SQL (#1Z0-007)
and Oracle 9i Database: Fundamentals I (#1Z0-031)exams.
I was wondering if its better to buy oracle press books or to go with self study CD Roms. I think the self study CD roms costs a lot between $400 to $750 where as the OCA Oracle9i Associate DBA Certification Exam Guide by Jason S. Couchman, Sudheer N. Marisetti costs around $90.
I would really appreciate if anyone could give me list of books that I can refer or tell me how to go about studying for OCA/OCP and which books/cd's to buy
thanks
bani
17 years ago
when i change line 1 to
System.out.println("" + t1)
then i getting the result as "null" .
In case of line 1 ie
System.out.println(t1)

Here System.out.println method will try and call toString method on null. Which results in a null pointer exception!
Correct me if i am wrong.
bani
I found this question on jiris.com
I was thinking the pgm will print null and 2
but the explanation given by jiris is entirely different.
Its strange that
System.out.println(t1.toString());
will run properly with output null.
I came across this question in one of the mock exams.
class Test001
{
int i;
public Test001(int i) { this.i = i; }
public String toString()
{
if(i == 0) return null;
else return "" + i;
}
public static void main(String[ ] args)
{
Test001 t1 = new Test001(0);
Test001 t2 = new Test001(2);
System.out.println(t1); //1
System.out.println(t2); //2
}
}
The answer is : throws exception at runtime.
can some please explain this to me?
thanks
bani
this code will give complier error at line 8.
static class StaticNested cannot access instance varible int c.
Top level nested classes does not have access to non-static members of the enclosing class.
-bani

- the code assumes both integer were initialized with 0 value. Does java always initialize variables for me? If so, with wich values are a boolean and a char initialized?


variable a is an instance variable and b is a static variable in the above code.

Static variables are initialized to default values when the class is loaded,if they are not explicitly initialized.

Instance variables are initialized to default values when the class is instantiated,if they are not explicitly initialized.
Local variables have to be initialized explicitly.if they are not initialized when they are instantiated at method invocation,compiler reports an error.
if a boolean variable is declared as static/instance variable then it is set to its default value ie false
Here is a list of datatypes and their defalut values
datatype default value
boolean false
char '\u0000'
Integer(byte,short,int,long) 0
Floating-point(float,double) +0.0F/0.0D
Object reference null
-bani
Dan, you have a great mock exam site out there and it has helped me a lot ( to clear my concepts) .These mock exams are a great resource to people who are preparing for SCJP.
Thanks again and keep up the good work.
-bani
No constructor can never be static
I tried compiling this program
import java.awt.*;
import java.applet.*;

public class Excercise extends Applet {
public void init() {

Frame f = new Frame("First Frame");
f.setSize(200,200);
String E = "Excercise- test area should not have scrollbars and should not be editable ";

TextArea ta = new TextArea(E,8,TextArea.SCROLLBARS_NONE);
ta.setEditable(false);
// ta.setBackground(Color.black);// line 1
// ta.setForeground(Color.yellow); // line 2
f.add(ta);
f.pack();
f.setVisible(true);


}
}
I am getting the folloing compiler error. ie error at line 1 and 2
Excercise java:14:No variable black defined in class Color
Excercise java:15:No variable yellow defined in class Color
can anyone pls tell me whats happening?
Am i missing something??
-bani
check this out http://www.geocities.com/danchisholm2000/
Robert, if u know the trick to remember Unicode ,could u pls explation
thanks
bani
Thanks Zarina.
Don,thanks for the explanation.
Your exams are of great help to people like me who are preparing for SCJP.You have done a great job.Thanks again Don.
-bani
By changing which line in the following code can you make the class compile with no errors?
class Xtc {
protected static void main(String args[]) {//line 1
byte b = 10, //line2
c = 10 , //line 3
x= (byte) (b + c) ; //line 4
System.out.println(" x is " + x); //line5
}
}
Options
a) line 1
b) line 2
c) line 3
d) line 4
e) line 5
f) None , the class compiles with no error and prints 20
He says the ans is (f) None
I marked it as (a) since main() must be public as the class will compile only if line1 is changed to public static void main ( String args[])
can anyone tell me why the answer is none, i tried compiling the program but compiler says main must be public and static.
thanks in advance.
bani