Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic