executing java program with 2 classes

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









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
how to create classes for lift program
how to create classes for lift program  i would like to know creating classes for lift program
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
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 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
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
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 classes
Java classes  What is the Properties class
java classes
java classes  What is the ResourceBundle class
Java classes
Java classes  What is singleton pattern
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... an example to further clarify the use of Java classes, object and its methods. Here...? Downloading JDK (Java) Writing Hello World Java program
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
Java list of uninstantiated classes
Java list of uninstantiated classes  Java list of uninstantiated classes
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
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
C Program for Addtion of 2*2 Diagnol Matrix - Development process
C Program for Addtion of 2*2 Diagnol Matrix   Hello Sir, I want C Program to Do Addtion of Diagnol Matrix in C language. Plz Give Me   Hi Friend, Try the following code: #include void main() { int a[2][2
GWT supported java classes
GWT supported java classes  What are the methods and classes in Java which are supported and unsupported by GWT
Helper classes in java
Helper classes in java  helper 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
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
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
Program to read 2 integers using oops concepts
Program to read 2 integers using oops concepts  Write a program to read two integers with the following significance. ? The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter
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
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 FontMetrics classes
Java FontMetrics classes  What is the difference between the Font and FontMetrics classes?  The Font class provides mappings to fonts that are used to render text data onto the screen. The Font class maps
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
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
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
Member Classes, Inner Nested Classes in java
Member Classes        Member classes are defined within the body of a class. We can use member classes anywhere within the body of the containing class. We declare member classes
Java Classes
Java Classes conducted online by Roseindia include an elite panel of some... sure 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
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..._TO_REPLACE_1 C:\Java Test>javac DisassesmleExample.java Now run it using javap
Problem in executing macro enabled excel sheet using java
Problem in executing macro enabled excel sheet using java  Hi, I have written a java code which will read a excel sheet with macro enabled. then it will write data into sheet1 and sheet2 and it will execute a VB script
ModuleNotFoundError: No module named 'executing'
ModuleNotFoundError: No module named 'executing'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'executing' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'executing'
ModuleNotFoundError: No module named 'executing'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'executing' How to remove the ModuleNotFoundError: No module named '
Video Tutorial - Classes and Objects in Java
will learn what are Classes and Objects in Java program. You will also learn how to create classes in Java and the create the instance of class in your program... of roseindia.net explain the the core concept of Classes and Objects in Java program
How are Anonymous (inner) classes used in Java?
How are Anonymous (inner) classes used in Java?  How are Anonymous (inner) classes used in Java
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
write a program for creating html page with images and 2 buttons
write a program for creating html page with images and 2 buttons  write a program for creating html page with images and 2 buttons
Abstract Classes - Java Interview Questions
Abstract Classes  Why we cann't instantiate a Abstract Classes? Even if an Abstract Class does not have any abstract methods, but declaring the class...://www.roseindia.net/java/master-java/abstract-class.shtml Thanks (Roseindia Team
Executing anonymous pl/sql block and get resultset in Java
Executing anonymous pl/sql block and get resultset in Java  Hello All, I would like to execute the anonymous pl sql block and need to get the resultset object. I got the code which can be done by using cursors inside the pl sql

Ads