Divya Madugula

Greenhorn
+ Follow
since Aug 18, 2012
Merit badge: grant badges
For More
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
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Divya Madugula

fred rosenberger wrote:The first step is always to forget about java.

If I handed YOU a piece of paper with "4N, 5E, 2N, 3E, 6S, 8W", how would YOU find the area?

Tell us in English, step by step.



I really don't know how to proceed ... but if given a pen and a paper i would proceed this way :

//dividing the total area into smaller rectangles and summing up

4N,5E : (N and E would become the height and the width of the rectangle ) area : 4 * 5 = 20
2N,3E : (N and E would become the height and the width of the rectangle ) area : 2 * 3 = 6
6S,8W : subtracting the previously counted 2N,5E dimension (height becomes 6-2 and width becomes 8-5 ) area : 4 * 3 =12
summing up all that we get the area as : 20+6+12 = 38

But the problem here is with subtraction... The dimensions can be irregular ... while putting the things on paper ,
we come to know about the operation we are supposed to do while looking at the figure we assume ..,
but the question is identify merely using dimensions ... that's really twisted and is not easy to deal with !!!


well i was even thinking that i can approach the problem while counting total area of the bigger rectangle and taking away the unwanted regions area ...
its like .. go for the total dimension sum :
N : 4+2 , S: 6, E:5+3, W:8
if (N == S && E==W) then we can proceed // Calculating the total area and removing the unwanted part ... identification of the unwanted region is the main part ... but how do we identify that ???
6 * 8 = 48 // gives total area
5 * 2 = 10 // part to be removed in the above case
actual area accounts to : 48 - 10 = 38

else invalid dimensions : not a proper rectangle



11 years ago
Can someone help me with this problem ?? Seriously the problems logic is pretty tough .., I am not understanding where and how to start off with this problems solution !!!
11 years ago

gurpeet singh wrote:Except D and F all are right

when you do java -ea Two, this means that you are enabling assertions for all classes. in your case it will enable assertion on Two as well as one

when you do java -ea:One Two, here you are enabling assertion on only class named One and disabled for class Two. so -ea:one means enable assertions on one, while running Two.

also when we do java -ea:com. Two , this means enable assertions on the package com and all its subpackages.

also suppose class Two is in a package com.guru and you do java -da:com -ea:Two Two, then assertions will be enabled for class Two, because the jvm sees the most specific setting for a class.




Firstly , Thank you for giving your time to explain. I still have a problem understanding the problems code ., why are options C,E,F,G incorrect ? I am confused !!!

In class One,
int x = 0;
{ assert x == 1; } must always return an error whenever assertions are enabled .., isn't it ?
class One {
int x = 0;
{ assert x == 1; }
}
public class Two {
public static void main(String[] args) {
int y = 0;
assert y == 0;
if(args.length > 0)
new One();
}
}

Which of the following will run without error? (Choose all that apply.)
A. java Two
B. java Two x
C. java -ea Two
D. java -ea Two x
E. java -ea:One Two
F. java -ea:One Two x
G. java -ea:Two Two x


Can someone please explain this !!!
A and B will work for sure as assertions are not enabled.
The rest of the options are a bit confusing because its involving 2 classes here !! please help !