General questions related to Java

Good evening,I would like to ask you some questions related to Java :
1) class A {
public int x=1;
public int y=5;
public A() { y=6; }
public A(int a) { x=a; }
public A(int a, int b) { x=a; y=b; }
class B extends A {
public B() {}
public B(int a) { super(a); }
public B(int a, int b) { super(a,b); }
public B(int a, int b, int c) { x=a+b+c; }
public B(int a, int b, int c, int d) {
super(a,b); y=c+d; }
public class Test {
public static void main(String[] args) {
B b4 = new B(1,1,1);
System.out.println("b4.x: "+b4.x+" b4.y: "+b4.y);
I cannot understand why y = 6.
As i see it,i find it more logical that y = 5.
Could anybody tell me why y becomes 6?
How did we get into the constructor of A : public A() in order y to be changed?
2) Well in an exercise i have to handle out we have to find the a,b,c of a program .Unfortunately i dunno about them,Can anybody explain to me what do they mean or attach me a link (e.g. a tutorial) in order to figure out?
a)pre condition in Java
b)post condition in Java
c)invariant condition
3)
3) Fraction apple = new Fraction (1, 2);
Fraction peach = new Fraction (4, 5);
Fraction pear = apple;
peach.halve();
pear.halve();
System.out.println(apple);
System.out.println(peach);
System.out.println(pear);
It's the first time i see an object as a parameter in System.out.println.
CAn anybody tell me when i can pass an object as an argument in System.out.println?
Thanks in advance!

How did we get into the constructor of A : public A() in order y to be changed?if you don't explicitly call a super constructor, the empty super constructor is called for you. If no empty accessible super constructor is available and no explicit call from subclass is made - compile error.
CAn anybody tell me when i can pass an object as an argument in System.out.println?Whenever you want. Object.toString() will be called and the resulting String will be used. If the object is null, the String "null" will be used instead.

Similar Messages

  • Question related to Java Concurrent Program

    Hi Friends,
    I have a basic question related to Java Concurrent Program in the Oracle application. I would like to know the how Java concurrent program is executed in Oracle applications.Also, want to know where can I find the document for the AOL packages for Java concurrent program. Document for packages like oracle.apps.fnd.cp.request.* , oracle.apps.fnd.util.*.
    Please let me know.
    -Thanks,
    Satya

    You may also check:
    Note: 250964.1 - How to Register Sample Java Concurrent Program
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=250964.1
    Note: 186301.1 - How to register and execute Java Concurrent Program ?in Oracle Applications R11i?
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=186301.1

  • Some general questions about Sun Java Communications Suite

    Hello Everybody,
    We are a small group of individuals (2 Java developers and 1 Linux expert and Web Application developer), located in Germany.
    We are fully new to �Solaris� and Sun Java Communications Suite and know, that it�s a highly professional software system for large scale deployment. However we plan to install (64 Bit version) and manage it in a small network environment, consisting of a Server (4 GB RAM, RAID 5, AMD Dual CPU) based on Solaris 10 (X86) and *20* clients based on Win XP, Solaris and Linux.
    It�s a network of a non-profit organization, providing social services to local society.
    At clients we will use the Communications Express and the needed services are: Calander, Mail and Address book. (no need of Outlook Connector, Instant Messaging, Document Management, etc.)
    Our long-term aim is - after learning of professional architecting, deployment and management of Communications Suite - to provide integration and development services to organizations (schools and small / medium sized Business) and public in cooperation with ISP or infrastructure-providers like Sun Microsystems.
    Now, our main questions are:
    *1.-* Is the Server phy. recourse enough to deliver the mentioned services of Communication Suite to 20 clients without problems?
    *2.-* Isn�t Communications Suite oversized for such small network mentioned above or better, if we use another collaboration software system like Opengroupeware (http://opengroupware.org/) ? Opengroupeware is developed using non-java lang and therefore doesn�t match our strategy.
    *3.-* Does the Communications Suite download-pack includes all necessary components of Sun Java ES (Directory Server, Access Manager, etc.) or these components are to be downloaded separately?
    *4.-* What is the difference between the Sun Java System Messaging Server and the Sun Java System Message Queue?
    We appropriate very much your answers and any further useful information regarding our project.
    Thanks
    Asghar

    1> I believe your hardware can support 20 users (you might need to tune the Web Server heap size) - I had a Sparc 2x450mhz w/ 2GB of ram supporting 50+ users quite comfortably - with roughly half using POP and the other half IMAP/webmail. Ideally though, for best performance you would want to break up the main servers (LDAP, WEB, and MS) between hosts) - probably not necessary for 20 users. Having all on one machine simplifies things too (but also makes it a single-point-of-failure). Your disk obviously is important, the faster the better - that it's redundant is also nice - larger deployments might use much fancier storage systems to provide speed and redundancy, and use an the App Server instead of the Web Server as a container for Comms Express.
    2> I don't think it's "oversized" - might you mean overkill? In this case I don't think overkill is a bad thing. Why not have very capable software, even if you don't really need it -is how I see things.
    3> I believe you get all you need in the download. Though I've never tried the 64bit version (which I am guessing is only really necessary for larger deployments where you want to obtain maximized performance for heavier loads). I recommend following the single host evaluation document to get the hang of the install.
    4> I'm not sure - though the Messaging install I believe requires the MQueue stuff, I think it's sort of an API for messaging, also available separately, but used by JES Messaging system?
    Good Luck,
    s7

  • Question relating to Java printing and where to post...

    First of all I am not a developer, but I have a question regarding printing in an application that was developed using Java and am not sure where to post it. I'll pose the question than defer to a moderator to move it if necessary.
    Here's the issue and question:
    We are using an application that has a host/client structure on several systems that use Windows Vista and XP. I have been told by the support team for this application that they use Java for printing tasks. I don't know if the entire application or just the print engine were developed in Java.
    Here's the problem:
    Whenever I tell this app to print for the FIRST time after opening the app, it takes between 4 and 5 minutes before it brings up the print menu. Again, this ONLY happens the FIRST time I tell it to print, and subsequent print commands are processed in a more normal timeframe.
    If I close this app and immediatly open it again, it goes through the same silly wait time for the FIRST print only.
    Tech support had me update Java to the latest incarnation on all machines, but that changed nothing. The guy even had the GALL to blame Java for the issue, can you believe that???
    Anyway, my question to you people here - that develop with Java - is what in the world this app ( and I suppose Java ) could possibly be doing with this print job for 4 to 5 minutes?
    BTW... these are NEW systems, with Dual-Core processors and a minimum of 1.5 gigs ( the server has 3 gigs) of RAM. Oh, and what I am printing is simply text, no graphics, just plain simple text.
    Any and all comments/suggestions appreciated...
    bob

    Thx ChuckBing,
    I agree with you about the application being the most logical source of the problem, and I have already provided their support with all the details that you suggest.
    I'll look at the link you provided and see if anything there steers me in a direction....
    bob

  • A few general questions relating to H55-GD65 and core i5 750 Lynnfield

    I finally made the jump from AMD to intel, and DDR3 ram, been reading the forums for around 3hours, been a member for 2hrs. Been building systems since Redhat 9.0 came out, so Don't expect any thing as funny as Quote
    because I want to know the temperature of the IOH without the heatsink.
    Would it be better to run 2gig X 4 = 8gigs of RAM, or 4gigs X4 = 16 gigs?
    Concerning dual channel mode, must I buy them in matched sets, or can I buy one stick at a time, obviously buying the same exact kind each time?
    To run DDR3 1600mhz on this board will I need to set the voltage/timings manually, or will it auto detect?
    From what I've read the pcie controller is on die, and with the i5's you can only run 1@ X16 or dual X8, am I correct?
    If I get a pcie x8 sas raid controller card, will it affect graphics performance?
    Also this will be my first attempt at dual booting sata hard drives.
    Would it be difficult to have win7 x64 on the mobo's onboard sata, and linux (either Mandriva, Open Suse, or gentoo if my insomnia is still acting up)
    on the sas card?
    Edit: Almost forgot, has any one else had issues with the onboard NIC dropping connection? It never happens when It is in use, only when i walk away from it, as an example Wow's latest 4gig patch had 900megs to go on a 1.1megabyte connection, upon going to sleep and locking the computer windows key-L, woke up with it having 500megs remaining and as soon as i opened my browser my connection picked right back up

    Hello and welcome,
    Quote
    Would it be better to run 2gig X 4 = 8gigs of RAM, or 4gigs X4 = 16 gigs?
    Concerning dual channel mode, must I buy them in matched sets, or can I buy one stick at a time, obviously buying the same exact kind each time?
    To run DDR3 1600mhz on this board will I need to set the voltage/timings manually, or will it auto detect?
    Its better to use 2x4GB, to lessen the strain on the memorycontroller and yes, you'll have to set it to 1600MHz yourself most of the time.
    The memorycontroller is rated for 1066/1333MHz, so anything beyond is considered overclocking and thus the controller will not set those higher timings automatically.
    Do you really need 8GB? For office, internet and gaming, normal homeusage, 4GB is more then enough, 8GB is nice if you render a lot or if you use cad/cam and photoshop stuff
    Quote
    From what I've read the pcie controller is on die, and with the i5's you can only run 1@ X16 or dual X8, am I correct?
    If I get a pcie x8 sas raid controller card, will it affect graphics performance?
    Yes it runs @x8 when running 2 vga's, or in your case if you use a PCIe x8 card, but the impact is none, even the GTX480 and the HD5970 are not capped when @x8, so no worries there.
    Quote
    Would it be difficult to have win7 x64 on the mobo's onboard sata, and linux (either Mandriva, Open Suse, or gentoo if my insomnia is still acting up)
    on the sas card?
    I have had dual and even triple boot since XP and never had any issues, be sure to write the different os to different hd's or partitions. About Linux on a sascard, no idea, Im not familiar with that.
    Quote
    Edit: Almost forgot, has any one else had issues with the onboard NIC dropping connection? It never happens when It is in use, only when i walk away from it, as an example Wow's latest 4gig patch had 900megs to go on a 1.1megabyte connection, upon going to sleep and locking the computer windows key-L, woke up with it having 500megs remaining and as soon as i opened my browser my connection picked right back up
    Check your windows powersavings settings, maybe it turns it off when in standby/sleep mode.
    If you cant find anything there check bios, to make sure onboard NIC is always on, although I believe  you must find such a setting in windows.

  • Intercompany Transaction Module - General Questions

    I do not have any real experience in using the Intercompany Transaction Module and have some general questions relating to the applicability of deploying this module at my site...
    The underlying GL systems capture Intercompany balances - but not the ICP entity detail. Therefore for each ICP Account the Trial Balance load into HFM (via FDM) will load the ICP Account balances to the [ICP None] member. We were originally going to provide a form through which these balances could be cleared from [ICP None] to the valid ICP members.
    However, a need to load multi-currency transactions has emerged putting the Intercompany Transaction Module under consideration.
    Not sure how the use of this module would work alongside the balances already loaded in the GL Trial Balance? Does this module merely allocate the existing balances or would we need to write a rule to reverse out of [ICP None] the values loaded via transaction to ICP Entities?
    Any advice will be appreciated

    By default, [ICP None] and [ICP Entities] will aggregate to [ICP Top],but there is one application setting: ICPEntitiesAggregationWeight
    this setting Specifies the percentage of intercompany partner entity [ICP Entities] amounts that aggregate to the [ICP Top] member of the Value dimension. By default, the value is 1, you can specify it to be 0, and using validation to make sure [ICP Entities] =[ICP None], then [ICP Top] will only =[ICP None] and will not double count.

  • General Question on Proxies

    Hi,
    I have few general questions....
    How to decide which proxy to be used: Java or ABAP?
    What are the deciding factors?
    Which one is better when it comes to performance?
    Regards,
    Rajani Kumar

    bump

  • Basic Questions related EHPs for SEM

    Hi Guys,
    I've some basic questions related to EHPs: -
    1. If we don't mean to implement any of the new functionalities does it make any sense to implement EHP? In other words do EHPs also have some general improments other than the functionalities which can be specifically activated?
    2. If we just activate a functionality and don't implement/ use it can there be any negative impact?
    3. In case of a pure technical upgrade from SEM 4.0 to SEM 6.0 which EHP would be recommended?
    4. Is there a quick way to find all relevant notes in EHPn which are related to corrections for EHPn-1?
    Thanks in advance,
    -SSC

    HI,
    If you see some of my older posts I have had many issues with certain features of the EHP2 functionality but that doesn't mean I would recommned against it.
    BCS 6 EHPs 3 & 4  (BCS 6.03 / 6.04) - enhancement packs worth implementing?
    BCS 6 EHP 2 (BCS 6.02) - activation of enhancement pack
    My recommendation is to implement the EHPs but not necesarrily activate the functions (in SFW5) unless you need them - this means that you will only have to test once after EHP implementation and will have the ability to activate the other features as and when required (although testing is required after activation of course) whereas it might be difficult to persuade your client/basis team to implement EHP4 later if you don't do it now.
    In the features of EHP2 (activate FIN_ACC_GROUP_CLOSE) it states that there is a general performance improvement - although I have yet to experience it! From OSS note 1171344 "The functionality which is available in EHP2 consists of...
    ... Performance improvements of status management, reporting and initial start-up of consolidation workbench and monitor.
    Since activating FIN_ACC_GROUP_CLOSE I have had many OSS notes requiring application but i discovered that when the technical team implemented the EHPs (before i joined this client) they somehow forgot the latest SP (support packs) and didn't upgrade to the current level - so make sure that you get the right SPs too (see the links in Greg's link above) to avoid the many OSS notes.
    As for your question - "is there a list of OSS notes to specific to EHP upgrades? - the answer is most definietly "NO" - I already asked OSS in desperation!
    however, you can see the OSS notes that i have applied listed in the above link ( BCS 6 EHP 2 (BCS 6.02) - activation of enhancement pack )

  • Some questions related to SAP XI

    Hello!
    I would like to know the answers for the following questions regarding SAP XI-context (if it possible with Yes/No and a short comment/explanation)
    <b>CAPACITY PLANNING GUIDELINES</b>
    a) Guidelines to size the server(s)?
    b) Guidelines for sizing the over all environment for High-Availability
    <b>ARCHIVING CAPABILITIES</b>
    a) Approach to archiving of obsolete data
    <b>PLATFORM SUPPORT</b>
    a) Software supported on HP-UX 11.i V2 (r6) on Itanium.
    b) software supported on Windows 2003 sp1 (x64) on AMD Opteron 
    c) software support aligned with release roadmaps for future versions of HP-UX and/or Windows Server
    d) Software supported on OS clustered servers  (If mutliple products, please indicate if all are support or list areas where clustering may not be recommended and why)
    <b>RELATIONAL DATABASE </b>
    a) Does your system run native to the Oracle 10g RDBMS (RAC) and database tools?  If not, please explain the databases and tools supported.
    b) database monitoring tools be used to manage impending maintenance needs and potential problems and performance impacts (i.e., tool will monitor and detect prior to real problem occurring)
    c) standard pre-defined SQL queries and related calculations provided for use with industry standard reporting tools
    d) database accept binary-large-objects (BLOBs) and  be referenced via the relational engine.
    Thank you in advance!
    Regards!
    A.Henke

    two questions related to this:
    1. Why Java is designed to only permit single
    inheritence, any stories behind the scene? I think
    some major reasons why "prefer interfaces toabstract
    classes" is accepted is rooted in this limitation.Yes, one of the reasons interfaces are better is that
    you can only extend one class, but implement many
    interfaces. Say you have a concrete class that should
    "implement" two different types. If those types were
    defined as abstract classes, you could only use one
    type. You could implement both types if they were
    interfaces though. So why java is designed to have this limitation? There may be some arguments before this is settled down. I always like to hear this kind of stories:)
    2. Base on the fact that once an interface is outof
    box and widely implemented, it is almostimpossible
    to change it. So how you guys design yourinterfaces?
    Could you share some? In my idea, I would designmy
    interfaces as compact as possible.You could extend the interface and start using that
    if you didn't want to break existing code. You
    couldn't use that implementation as an Interface1
    though, since the new methods only exist in
    Interface2, so that's not an optimal solution.So we may always need to add a new interface when we just want to add a new method.

  • Question related to SCJP 6 certification

    Hi Everyone,
    Just have question related to SCJP Exam.
    I have started to prepare for SCJP 6 from yesterday (3-4 hours in a day) and I am planning to take SCJP exam in march last week. can u suggest books, which I need to go through..and also I need to write exam at earliest..Do I need to take more than one month for preparation....or less than that is it possible for good knowledge and score?
    Thanks,
    Naveen

    Hello Naveen,
    I am also goining to write SCJP1.6 exam(hopefully this month end).
    I am referring Kathy Sierra, Bert Bates SCJP1.6. It is an awesome book and it include 350+ mock question excluding the ones you get at end of each chapter.
    I dont know whats the level of your Java knowledge. In my opinion someone who has a fair amount of knowledge of the subject should take atleast 2 month of preparation before taking the exam. Syllabus for SCJP6 is more or less easy(except for few concepts) but you know what makes it a difficult exam is the minor details which we tend to ignore while studying the Java subject.
    Also the questions will contain more than 1 correct answer which you cant answer correctly unless you have pracised a lot of mock exams.
    So my advise to you is :take time to brush up the minor details of the subject and do lot of mock tests. That ways you can ensure good marks.Dont hurry, else you may clear the exam but not with good percentile.
    Thats all knowledge I wish to give you.
    Let me know if you want some more.
    Best of Luck for your exam,
    Best regards,
    Suvojit CHAKRABORTY

  • Question related to the  JAX-RPC.

    Hi ,
    I have a question related to the JAX-RPC API.
    Please clear me following points whether I am right or not?
    1. If my two end points are in Java then and only we use the JAX-RPC API. Is it right?
    2. If my two end points are in .Net then we use the some other API in .NET. Is it right?
    Please give me links or associate info. regarding this.
    Thanks,
    Rahul

    With JAX-RPC API, you are writing or consuming web services. If you are building web services, then that web service should be interoperable to .NET as well as Java. You do not have to use JAX-RPC, because, JAX-WS can serve the same purpose but is much easier to program. More about web services may be found at [http://soalib.com|http://soalib.com]

  • Validation General Questions

    I have a couple of general questions on validation.
    1) I have a text field defined as a "Required" field (it is using the form_required template). Must I also create a NOT NULL validation on this field as well? It seems that I should not have to do this. However, if I do not create this NOT NULL validation, then clicking on a Submit button while this field is empty is not generating any error message. But when I include a NOT NULL validation, then I do get an error message.
    2) This question is related to the first. I tried creating a regular expression validation on my field in which I use the pattern
    [[:alnum:]]{1,}[|$#&_?]+
    The field should allow the user to type-in a string consisting of 1 or more alphanumeric characters (it could be a foreign language characters as well)
    and 1 or more special characters like $ or #.
    I thought this would also generate an error message if the user clicks the Submit button while leaving the field empty. But, again, I get no error message. Why?
    Thank you in advance for any insight on this.

    Thanks very much, Justin.
    When I saw the regexp_like() function in your reply, I am wondering if, perhaps, you might also have some insight into how I can ckeck if a field contains non-English type characters (i.e., mult-byte characters). I already posted a question about this an hour ago but have not gotton any replies as yet. In my post I asked about using the regular expression pattern [[:alnum:]] since the docs state that this will check for mult-byte characters. And so, I thought if perhaps there is some function I might use to return a boolean TRUE if a field contains non-English characters versus a FALSE if it contains only English characters.
    Any insight in this would be most appreciated.
    Thanks again for your help.

  • Posting general questions

    As a new user to apple forum discussions I find it a very user unfriendly system. Een finging how to view discussions took me over half an hour, and to post a question even longer! Now I cannot find where I should go to post a general question not related to any of the lists on the forums homepage. Very frustrating! Can anyone advise me how I open an account online since I cannot get the system to accept my details since my country, South Africa is not in the international list. Surely one can use a credit card without having to fill in a physical address!? I wish to get Quicktime Pro and cannot as it is not on the shelves and I can't get past this address problem!
    Thanks,
    Kendrew.

    Joe Dew wrote:
    You figured out how to post a question. I haven't figured that out yet. What's the trick?
    Joe ~ Welcome to the discussions. See here:
    http://discussions.apple.com/help.jspa#postquestion

  • Lead File Attachments General Question

    Lead File Attachments General Question, can attachments somehow be made in the full edit view?

    Attachments are Related Objects till R17. So it can not be seen in Full-Edit Mode.
    In R18, one attachment is available at the Object Level.
    Trust this helps.
    Akesh

  • General question regarding "parallelism" of iPhone execution

    I've got a general question and hope somebody can shed some light on this.
    While I'm relatively new to iPhone development I've been in software programing for more than 15 years now and have a solid background in Java, C, C++, C# and other languages. I've created a couple of applications for the iPhone, easy and complex ones, some using UIKit, others using Open GL and Open AL. With that said I think it would be fair to say that I know pretty much what I'm talking about.
    For those who tend to refer everybody back to the Apple Samples or PDF guides, please believe me, I've read them all.
    Here's my "question":
    I occasionally ran into a situation where I got the impression that code on the iPhone got executed in a "non sequential" or "parallel" manner even when I did not explicitly created threads. I'm not referring to code buried in a framework or so, I'm talking about code I've written. (English is not my mother tongue, so please excuse me if my explanation might be somewhat difficult to understand.)
    I try to give an example. Assume a code snippet like this:
    _gameEngine = [GameEngine alloc];
    [_gameEngine initSomeStuff];
    In my understanding the second statement (the initSomeStuff) gets executed once alloc returns and _gameEngine for sure is a valid pointer. Is that fair to say? I sometimes got the impression that the iPhone starts executing code without waiting that a method returned.
    I had similar issues when I tried to show an ActivityIndicator while another method was doing a lengthy operation. Pseudocode like this:
    [_activityIndicator show];
    [self longLastingOperation];
    [_activityIndicator hide];
    In code like the one above: Can I be 100% sure, that the hide message is not sent until longLastingOperation returns? I ran into a situation where I had the impression that show and hide got called immediately without waiting until longLastingOperation returned.
    Final example:
    [self performSelectorOnMainThread:@selector(doSomething) withObject:nil waitUntilDone:YES];
    [self nextStatement];
    -(void)doSomething {
    [self longLastingOperation];
    1.) In the above code, I understand the idea is that doSomething will be executed on the MainThread and that nextStatement will in no way be executed before doSomething has returned. Is that true?
    2.) doSomething is supposed to run on the MainThread but does this hold true for longLastingOperation, too? Or could it be that longLastingOperation WITHIN doSomething gets dispatched to another thread and doSomething returns PRIOR to longLastingOperation been finished?
    This might all sound pretty wired but as I said from time to time I ran into a situation where I got totally confused as to how stuff executes in – or out of – sequence. I helped myself with using NSNotificationCenters etc. but I'd like to understand what's going on in detail and crystal clear here.
    Your help is more than appreciated.
    Thanks,
    R.
    Message was edited by: BeSharp

    It is never safe to assume that any allocation was successful, and while it's incredibly unlikely that you're running into any such situation, it's entirely possible for a formal protocol to declare that a given message send should return immediately without waiting around:
    http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ch apter13_section_8.html#//appleref/doc/uid/TP30001163-CH9-BAJIGHAF
    An "impression" doesn't prove much unfortunately, so I'd recommend getting friendly with the debugger to see what's really going on.

Maybe you are looking for

  • Where is the device list for lost or stolen Ipads?

    Where can I find a list of serial numbers associated with my Apple ID?

  • Reg: sum() function in XML

    HI frs, while using sum function in Xml.not getting correct output. for ex: i have created report with emp table. load the xml into MS-Word. i want to sum total of salary of employees. i used SUM() function to calculate but in output it adds twice th

  • New Line

    I have recently ordered a new line, i was due to have a enginneer out tomorrow to connect it all up and what not. I got a text through the other day to say that my line would be connected early and the appointment was not needed. All well and good i

  • Quik save not saving attachment - Outlook Intergration

    Hi All, My client when saves an  e-mail with attachment as an Activity using the Quick Save email option in Outlook It just saves the email as an Activity but no attachment. The email attachment is getting saved only if using the normal Save email as

  • PO confirmation/AB acknowledgement

    Hi Friends, I need your help/suggestion on PO confirmation. I am using a confirmation control key which requires AB first followed by LA(ASN). For some reason, I do not see the AB confirmation getting populated automatically through IDOC. I checked t