executing java program with 2 classes

Ads
 

executing java program with 2 classes

how to run a program of java containing more than one class....ex of program is given below....

class C { int x; int y; }

class D { public static void main(String args[]) { C c1,c2; c1 = new C(); c2 = new C(); c1.x = 10; c1.y = 20; c2.x = 6; c2.y = 7; system.out.println(a1.x+"\t"+a1.y); system.out.println(a2.x+"\t"+a2.y); } }

View Answers

February 19, 2011 at 10:47 AM

Executing java program with 2 classes

save the file with D.java:

class C {
    int x;
    int y; 
    }

class D {
    public static void main(String args[]) {
        C c1,c2;
        c1 = new C();
        c2 = new C();
        c1.x = 10;
        c1.y = 20;
        c2.x = 6;
        c2.y = 7;
        System.out.println(c1.x+"\t"+c1.y);
        System.out.println(c2.x+"\t"+c2.y);
        } 
        }

Ads









Related Tutorials/Questions & Answers:
executing java program with 2 classes
); } }   Executing java program with 2 classes save the file with D.java...executing java program with 2 classes  how to run a program of java containing more than one class....ex of program is given below.... class C
while executing a java program
while executing a java program  while iam executing a simple java program after i type "java simple.java" there was a an error occuring.the error is "exception in thread "main" java.lang.noclassdeffounderror:simple" what thus
Advertisements
write a java program that implements the following classes:
write a java program that implements the following classes:  write a java program that implements the following classes: A) a) Point in the Cartesian... and cylinder and spere are subclasses of the circle class. All these classes should
ERRor in executing DB program
ERRor in executing DB program  While executing following code an Error was generated.can any one help me for this. LiveDB liveDBObj... = liveDBObj.getPreparedStatement(qry); pstmt.setDouble(1,2.0); pstmt.setString(2,"name1"); int i
how to sort the result of this 2 class program in java.....????
how to sort the result of this 2 class program in java.....????  package setget1_method; import java.util.Scanner; public class Main { { { Scanner input = new Scanner(System.in); LBook[] book = new LBook[5]; String
Inner Classes In Java
Inner Classes In Java       There are 4 kind of classes that can be defined in a Java program, roughly...; -- They are summarized here:   1. Static member classes   2. Member classes   3
how to create classes for lift program
how to create classes for lift program  i would like to know creating classes for lift program
Classes in Java
Classes in Java      ... in Java. The exceptions that occur in the program can be caught using try... of the program. An exception is an event that occurs and  interrupts
Java classes
Java classes are like a group under which all objects and methods... examples that will help beginners in Java understand the definition of Java classes... of Java classes, object and its methods. Here in order to determine Area
how to run java program that has several classes under package from usb drive?
how to run java program that has several classes under package from usb drive... command line and it works. I copied all java files and class files to flash drive... a1.cis568 under this package I have several classes. main class is A1.java and other
Java list of uninstantiated classes
Java list of uninstantiated classes  Java list of uninstantiated classes
Write a java program that encrypt and decrypt some string by adding or removing 2 on each character.
Write a java program that encrypt and decrypt some string by adding or removing 2 on each character.  Write a java program that encrypt and decrypt some string by adding or removing 2 on each character. Example 1 : Please Enter
Executing Set of SQL statements in Java
Executing Set of SQL statements in Java  Hi, I am trying to execute a procedure which is stored in MS SQL server's database. I have configured... the code for saving the data in excel but the code for executing the query
GWT supported java classes
GWT supported java classes  What are the methods and classes in Java which are supported and unsupported by GWT
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project. Or the data is stored in both database and java collection classes
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project. Or the data is stored in both database and java collection classes
My first struts 2 program
My first struts 2 program  Hi, Please help me for my first struts 2... from one page to another. Details: I am trying my first Struts 2 example program. I want to pass values from first loginpage.jsp to displaypage.jsp. I
Helper classes in java
Helper classes in java  helper classes
What is Abstract classes in Java?
What is Abstract classes in Java?  What is Abstrack class in Java...,   Hi, In Java programming language we are used the Java Abstract.... That's why the Abstract class in Java programming language is used to provide
Java application that uses the classes and
Java application that uses the classes and   i have this class diagram with three classes: Curriculum, Course, and Lecture. Your class diagram...) I wish Write a Java application that uses the classes and methods above
JAVA CLASSES/ SUPERCLASS
JAVA CLASSES/ SUPERCLASS  i. Define a class called Student and its two subclasses named underGraduateStudent and postGraduateStudent. Make... to display the students name. Write a test program that creates a undergraduate
creating java classes
creating java classes  This program uses a class named DrivingLicense... program to ensure that it generates the following output. Alice does NOT have... license /* Class: DLTest.java Description:Test program
java program
java program   You need to keep record of under- graduate, PhD... with the following attributes and method 1. Attribute Name: String 2. Attribute Address.... Write constructor for all the classes, and override method Get_info() for all
What are Classes and Interfaces in Java?
In this tutorial we are going to discuss about classes and interfaces in Java... language. Anyone learning Java programming language should learn classes and interfaces concepts in detail. What are classes? Java is Object oriented
Disassembling Java Classes - Java Tutorials
Disassembling Java Classes To Disassemble a class file in Java there is a tool... class of java. first compile them using javac then call the javap Class...:\Java Test>javac DisassesmleExample.java Now run it using javap as C:\Java
creating java classes
creating java classes  Create a Java class that can be used to store inventory information about a book. Your class should store the book title... a program that tests your class by creating and using at least two objects of the class
Java Classes
Java Classes conducted online by Roseindia include an elite panel of some... that if a beginner starts taking a Java classes online here, than he/she at the completion of the program becomes a Java professional and at later stage becomes
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
Moire Pattern 2 Java
Moire Pattern 2 Java   textWhat you are seeing in the screenshot... and height are the same. Make the program from this older code: import...; g2.setColor(Color.black);g2.fillOval(centerX, centerY - ovalWidth / 2, 300, ovalWidth
java code 1 of 2
java code 1 of 2  Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes   Hi Friend, Visit
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??  import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements

Ads