Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners executing java program with 2 classes
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


anuj
executing java program with 2 classes
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


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); } }


Advertisement
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);
        } 
        }


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
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
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
java 2 d array program
java 2 d array program  write a program 2-d matrix addition through...[][] A = new int[2][2]; int[][] B = new int[2][2]; int[][] C = new int[2][2...]+" "); } } System.out.println(); System.out.println("Sum of 2 matrices,Matrix C
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
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
Java classes
Java classes  Which class is extended by all other classes
java classes
java classes  Which class is the super class for all classes in java.lang package
how to create classes for lift program
how to create classes for lift program  i would like to know creating classes for lift program
java programe executing error - Java Beginners
java programe executing error  i am creating one package to one class... Friend, If you have following java class: package newp; class Hello...!"); } } Compile as: javac -d Hello.java Execute it: java Hello
Java classes
Java classes  What is singleton pattern
java classes
java classes  What is the ResourceBundle class
Java classes
Java classes  What is the Properties class
Java classes
Java classes  Why default constructor of base class will be called first in java
java classes
java classes  What is the difference between a static and a non-static inner class
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
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
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
java classes. - Java Beginners
java classes.  I con not understand the behavior of anonymous inner classes?   Hi friend, I am sending you a link. This link will help you. Please for more information. http://www.roseindia.net
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
Helper classes in java
Helper classes in java  helper classes
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
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
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
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
Advertisements
 

 

 

DMCA.com