Active Objects 1 Answer(s) 2 years and 11 months ago
Posted in : Java Beginners
Design a class for complex nos in java in addition to methods for basic operations on complex number. Provide a method to return the number of active objects created
View Answers
July 8, 2010 at 10:25 AM
Hi Friend,
Try the following code:
public class ComplexNumber { private int a; private int b; public ComplexNumber(){ }
public ComplexNumber(int a, int b){ this.a =a; this.b=b; } public String getComplexValue(){ if(this.b < 0){ return a+""+b+"i"; } else{ return a+"+"+b+"i"; } }
public static String addition(ComplexNumber num1, ComplexNumber num2){ int a1= num1.a+num2.a; int b1= num1.b+num2.b; if(b1<0){ return a1+""+b1+"i"; } else { return a1+"+"+b1+"i"; } } public static void main(String args[]){ ComplexNumber com1 = new ComplexNumber(-2,-3); ComplexNumber com2 = new ComplexNumber(-4,-5); System.out.println(com1.getComplexValue()); System.out.println(com2.getComplexValue()); System.out.println("Addition of both Complex Numbers are :" +ComplexNumber.addition(com1,com2)); } }
Thanks
Related Pages:
Active Objects - Java Beginners Active Objects Design a class for complex nos in java in addition to methods for basic operations on complex number. Provide a method to return the number of activeobjects created Hi Friend,
Try the following code
Active vibration Active vibration hello
is it possible to active vibration from code ?
if yes give me solution!!!
hiii
To trigger vibration in iPhone, use System Audio Services (AudioToolbox/AudioServices.h).
Call
active window means active window means active window means what?
The active window is the term used to describe the window that is currently being used
JDO - Java Data Objects Tutorials
JDO - Java Data Objects Tutorials
 ... Objects (JDO) tutorial will show you how to use
JDO to develop standalone... and retrieve the objects easily and efficiently.
At Rose India we have
Objects ObjectsObjects
In this section we are going to
illustrate how the real life objects are the key to understand object-oriented
technology
Objects are the part of our day to
day
Count Active Thread in JAVA
Count Active Thread in JAVA
In this tutorial, we are using activeCount() method of
thread to count the current active threads.
Thread activeCount() :
Thread class provides you to check the current active thread by providing
Login Authentication using existing Active Directory.
Login Authentication using existing Active Directory. I need jsp... Active Directory.
Here no need to create active directory.The JSP code should... or Active directory URL
problem. how to use active mq - JMS
problem. how to use active mq how to use active mq with jms. right now i am using struts 2.0 to develop small applications and i am using tomacat... and active mq please send me
Logout if its not active for longer period in jsp
Logout if its not active for longer period in jsp hi all,
Please tell me how to log out the application if its not performing any activity for longer period in jsp i tried to use session.setMaxInactiveInterval(arg0); but still
Data objects
Data objects hello,,
What are data objects?
hii,
Sequences, Views, clusters, Tables, index and cluster are called data objects for a database
Java Objects
Java Objects What are Data Transfer Objects and where are they used
classes and objects
classes and objects Define a class named Doctor whose objects are records for a clinic�s doctors. Derive this class from the class Person... and Billing, whose objects are records for a clinic. Derive Patient from
Classes and Objects
Classes and ObjectsObjects... the main() method.
A class can have more than one instances (objects), let us... techniques. A class defines the
properties of objects and methods used
Benefits of detached objects in hibernate
Benefits of detached objects in hibernate What are benefits of detached objects in hibernate?
Detached objects can be passed across... Transfer Objects). You can later on re-attach the detached objects to another
Objects in Java Objects in Java
Whatever we can see in this world all the things are a object. And all the
objects are categorized in a special group. That group is termed as a class. All
the objects are direct interacted with its class that mean
implicit objects in jsp
implicit objects in jsp hello,
how many implicit objects in jsp???
hello,
I am giving implicit object
out,config,page,application,request,page context,response,session
Flex Objects
: #FFFFCC;
}
Objects are real entity conforming the template or blueprint defined
by its class. The class defines the properties and behavior for its objects... objects of
these classes according to the need of your application
Transient and detached objects
Transient and detached objects Explain the difference between transient (i.e. newly instantiated) and detached objects in hibernate
Java Objects - Java Beginners
Java Objects Hi I have the following question, What method in Java is used to destroy your objects.
Thanks in advance
Program to implement array of Objects.
Program to implement array of Objects. Create a class it has.... Initialize an array of objects. Pass a name from the
command line & search for the name in the array of objects , if it is existing print the information
JDO UNPLUGGED - PART 1
)
Java Data Objects is an 'Object Relational Mapping' Technology
developed by Java Community Process(JCP), with active... for the JDO expert
group and David Jordan is an active member of that group.
Before
Objects - Java Beginners
Objects Hello, assist me crack this programming question.
Develop a class to represents a human. The head, arms and legs should be properties of the human and should be represented by separate objects. All of your objects
JSP Implicit Objects
JSP Implicit Objects What are implicit objects in JSP? and provide List them?
Thanks in advance
Hi,
In the JSP, the web container are created some method that are contain information related to a particular
Mapping objects in XML - Spring
Mapping objects in XML
Hello,
I´ve read that you can define an object in the configuration XML as follows:
tom
Ok, but, if I want to set a different value for "name" each time I create
Objects - Java Beginners
of the human and should be represented by separate objects. All of your objects...) {
//Declare and create a Headmain object
//and Three ArmsMain objects
Counting Objects Clandestinely - Java Tutorials
Counting Objects Clandestinely
2001-12-28 The Java Specialists' Newsletter [Issue 038a] - Counting Objects Clandestinely
Author:
Dr. Heinz M. Kabutz... Java programmers ;-).
Counting Objects Clandestinely
A few months ago I
Iterate list of objects on jsp page
Iterate list of objects on jsp page Hi,
I want to iterate the list of objects on jsp page using custom tags. Can you please give me one link or example?
Thanks
Counting Objects Clandestinely - Java Tutorials
Counting Objects Clandestinely
2001-12-28 The Java Specialists' Newsletter [Issue 038b] - Counting Objects Clandestinely - Follow-up
Author:
Dr. Heinz M... you use a "boolean counting" variable?
A: I want to avoid counting objects
remove all objects from NSMutablearray
remove all objects from NSMutablearray Hi,
How to remove all objects from nsmutablearray?
Thanks
HI,
Here is the code for creating NSMutablearray, adding objects and then removing all the objects:
NSMutableArray
Serializing Objects Into Database - java tutorials
Serializing Objects Into Database
2001-05-24 The Java Specialists' Newsletter [Issue 020] - Serializing Objects Into Database
Author:
Dr. Heinz M...", where I look at how we can serialize objects into
a database using JDBC. Thank
Classes-Objects in JavaScript
Classes-Objects in JavaScript
 ... Classes and
Objects of JavaScript and
create the examples of Classes and Objects... programming language so, its variables is
depending upon the objects. In object oriented
Map Java Objects with Database tables
Map Java Objects with Database tables How to map Java Objects with Database tables?
First write Java domain objects ie. beans with setter and getter methods. Then map java class to table and database columns to Java
save list of objects in Spring and hibernate
save list of objects in Spring and hibernate I use a javascript which add dynamic rows with values in jsp.
Now i want to save these multiple values using spring and hibernate.
Thanks for help
PHP Comparison Objects
Comparison of Objects:
There are several ways are provided in PHP to compare two objects of class (same or different).
There are mainly = =, = = = operators are used to compare two objects, and instance of operator can be used also