This week's giveaway is in the OCPJP forum.
We're giving away four copies of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) and have Paul Anilprem on-line!
See this thread for details.
Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

sitaram

Greenhorn
+ Follow
since Jan 24, 2008
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 sitaram

All methods must be implementing in the class.
method1(),method2(),method3(),method4().
Right shift operator
Right shift operator is signed. That means it can be positive or negative.

code:
---------------------------------------------------------------------------
But when we do 9>>2the answer is 2

9/2 ^
4-1 |
2-0 |
1-0 |
----
9-->1001
1*2^3+0*2^2+0*2^1+1*2^0 = 9

8+0+0+1=9.

This is the way of calculation.

Bit representation- 0000 0000 0000 0000 0000 0000 0000 1001
As we always add 0 from the left so-
0000 0000 0000 0000 0000 0000 0000 0010 (two digits are cancel)
0010
0+0+2+0=2.
Answer 2

--------------------------------------------------------------------------


a) Am i right with the answer?

b) As we always add '0'so there is no question of being signed or unsigned just as the unsigned right shift. Only the case if the number what ever given to be shifted right is itself negative then only the answer will be negative. ex -4>>2 then ans will be (-) irrespective of the calculation.
Am i right?

Left Shift Operator-

Left shift operator is signed. That is what ever the left most bit of the real number is ,that bit only get filled from right side means 0 or 1 and it get the sign as per it if 0 the positive or negative. Am i right?


code:
---------------------------------------------------------------------------

int a=29;a=a<<3;
0000 0000 0000 0000 0000 0000 0001 1101
After shifting 0000 0000 0000 0000 0000 0000 1110 1000(three digits(0) are adding in righthand side.

ans:232.
class HelSte{
String nat="dub";
public void jume(){
System.out.println("HelSte");
}
}

public class HarMol extends HelSte{
String nat="uk";

public static void main(String argv[]){
HarMol hm = new HarMol();
hm.go();
}

public void jume(){
System.out.println("HarMol");
}

public void go(){
HelSte hs = new HarMol();
hs.jume();
System.out.println(hs.nat);
}
}
--------------------------------------------------------------------------

The O/p of the Following Code is:-
HarMol
dub


and
suppose we are puting "static" word in all methods.

class HelSte{
String nat="dub";
public static void jume(){
System.out.println("HelSte");
}
}

public class HarMol extends HelSte{
String nat="uk";

public static void main(String argv[]){
HarMol hm = new HarMol();
hm.go();
}

public static tvoid jume(){
System.out.println("HarMol");
}

public void go(){
HelSte hs = new HarMol();
hs.jume();
System.out.println(hs.nat);
}
}
--------------------------------------------------------------------------

The O/p of the Following Code is:-
HelSte
dub
public static void main(String[] args){
int[] a = {1};
Test5 t = new Test5();
t.increment(a);
System.out.println(a[a.length - 1]); // o/p is 2
}
void increment(int[] i){
System.out.println(i[i.length - 1]++); // o/p is 1
}
class Test{ public static void method(StringBuffer sb){ sb.append(" Added"); sb = new StringBuffer("Hai"); } public static void main(String a[]){ StringBuffer sb = new StringBuffer("String Buffer"); method(sb); System.out.println(sb); }}

Answer:String Buffer

we can apply the any operations in the method.that operations are valied only that method.not outside.This is the main point.
Class T1{T1() throws exception{}
T1(int i){}}
Class T2 exends T1{T2() throws IllegalStateException{}
T2(int i) throws IllegalStateException{}
public static void main(String []arg) throws Exception{
T1 t=new T2();
}
}
Above program is not compile.because ,the exception is not declared properly.As per sun rule.
parent---sub-subException.
child1(sub-class)--sub-Exception
child2(sub-sub-class)----Exception

Regards,
D.Sitaram
java1.5 is very demand.because it as number of features.
1.Generics
2.autoboxing
3.stringbuilder,etc...
Hi,
non-syncronized classes are using only iterator.
syncronized classes are using only Enumeration.

Regards,
D.Sitaramayya.
Hi,

1. public class X {
2. public X aMethod() { return this;}
3. }
1. public class Y extends X {
2.
3. }
Which two methods can be added to the definition of class Y? (Choose two)
A. public void aMethod() {}
B. private void aMethod() {}
C. public void aMethod(String s) {}
D. private Y aMethod() { return null; }
E. public X aMethod() { return new Y(); }

Ans - C,E


A.overriden X.aMethod
The return type is incompatable with X.aMethod().
B.The return type is incompatable with X.aMethod().
C.aMethod is not overriden.
D.The return type is incompatable with X.aMethod().
E.Overriden X.aMethod.The return type is compatable with X.aMethod().

Regards,
D.Sitaramayya.
Which two are valid declarations within an interface definition? (Choose two)
Hi,
A. void methoda();
B. public double methoda();
C. public final double methoda();
D. static void methoda(double d1);
E. protected void methoda(double d1);

Ans - A, B

In interface,all methods must be public & abstract.static and final modifers are using in variable declaration.

Regards
D.Sitaramayya.
Hi Gupta Prakash,

In Abstract class ,Concreate methods and abstract methods declaration. Abstract methods are not compusory in the abstract class.
There is form.It as three fields and one button.client will enter the three fields and press the submit button. at the time,the request goes to the controller. The controller reads the Structs-config.xml.The controller will check where exactly matches the request that related form bean ,action class will be executed.then related forward page will be display on the browser.
14 years ago
Validations are checking automatic in this process.
14 years ago
Error:404 is Client-side problem.

Regards,
D.Sitaramayya.
14 years ago