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



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

Have Programming Question? Ask it here!
 
 
 


anuj
executing java program with 2 classes
1 Answer(s)      3 years and 6 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 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... 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
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 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
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
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
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
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
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
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 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
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
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
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
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
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
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
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 Hibernate application
) Java Result: 1 BUILD SUCCESSFUL (total time: 2 seconds) can you tell me...executing Hibernate application  when i am executing the hibernate application the following error occured. log4j:WARN No appenders could be found
Java 2 micro editionJ
Java 2 micro editionJ  Hello, i am using JCreator, for writing my J2ME program, after building the program, it keeps on given me the following errors: package javax.microedition.midlet does not exist package
Distinguishes JavaBeans from Java Classes
Distinguishes JavaBeans from Java Classes  What is the difference between a Java Bean and an instance of a normal Java class?Explain with an example, pls?   Hi Friend, Differences: 1)The java beans are serializable
classes and data abstraction - Java Beginners
classes and data abstraction  Create a java program for a class named... for Mexican pesos, f for Swiss francs, e for Euro dollars or q to quit...() is called. If the user enters 'q', the data member more is set to false to allow
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
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 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
Advertisements
 

 

 

DMCA.com