• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt with master exam q. 66 and 76 (q. 76 answered)

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried searching for answers to both of these questions, but wasn't able to find any. Here goes:

Q66
Shouldn't the default classpath be /foo/test instead of /foo to make this question correct, and to allow the program to compile and run without errors?

correct answer: "import xcom.B" added to TestXcom.java

foo
|
test
|--TestXcom.java
|
xcom
|--A.class
|--B.class

package xcom;
public class A {public void go() { System.out.println("a.go");}}

package xcom;
public class B extends A {public void doB() {System.out.println("B.doB");}}

class TestXcom { public static void main(String[] args) {
B b = new B(); b.doB(); b.go();
}
[ September 07, 2007: Message edited by: Emil Kastbjerg ]
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class Zeta{
public static void main(String[] z){
int x = 1;
if((4 > x)^((++x + 2) > 3)) x++; //line 1
if((4 > ++x)^!(++x == 5)) x++; //line 2
System.out.println(x); //line 3
}
}

at line 1
if((4>1)^((2+2)>3)) ->if(true^true)->false

at line 2
if((4>3)^!(4==5)) -> ((true)^!(false))->false
therefore x value is 4
and the o/p is 4
 
It's a tiny ad. At least, that's what she said.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic