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



Home Answers Viewqa Java-Beginners PROBLEM IN EXECUTION
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


anuj
PROBLEM IN EXECUTION
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners


class R { private int x; private int y;

  void getdata(int x1,int x2)
     {
          x=x1;
          y=y1;
     }
  void displaydata()
     {
          system.out.println(x+"\t"+y);
     }
}

class J { public static void main(String args[]) { R c1,c2; c1 = new R(); c2 = new R();

    c1.getdata(10,20);
    c2.getdata(30,40);
    c1.displaydata();
    c2.displaydata();
    System.out.println(c1.x+"\t"+c1.y);
    System.out.println(c2.x+"\t"+c2.y);
    } 
    }

//THE PROGRAM IS SHOWING 6 ERRORS 1.PACKAGE SYSTEM DOES NOT EXIT 2.X HAS PRIVATE ACCESS IN R 3.Y HAS PRIVATE ACCESS IN R


Advertisement
View Answers

February 21, 2011 at 11:21 AM


Java Program

Private modifier does not allow to access the private variable, method of another class.

class R {
     int x;
     int y;

  void getdata(int x1,int y1)
     {
          x=x1;
          y=y1;
     }
  void displaydata()
     {
          System.out.println(x+"\t"+y);
     }
}
class J {
    public static void main(String args[]) {
    R c1,c2;
    c1 = new R();
    c2 = new R();

    c1.getdata(10,20);
    c2.getdata(30,40);
    c1.displaydata();
    c2.displaydata();
    System.out.println(c1.x+"\t"+c1.y);
    System.out.println(c2.x+"\t"+c2.y);
    } 
    }


Related Tutorials/Questions & Answers:
PROBLEM IN EXECUTION
PROBLEM IN EXECUTION  class R { private int x; private int y; void getdata(int x1,int x2) { x=x1; y=y1; } void displaydata() { system.out.println(x+"\t"+y
getting a problem in execution - Development process
getting a problem in execution  hi friends i have a problem in imcms content managment system it is a java content mangment system it is according... the whole file i am getting a problem like in server.properties file
Advertisements
problem at the time of execution - JSP-Servlet
problem at the time of execution  when i was running web applications the exception i.e 404 resource is not available what it means and where it occures what is the solution   Hi Friend, This error occurs when
execution of a jdbc program
execution of a jdbc program  how to execute a servlet program that..uses a jdbc driver (i.e. using mysql-connector -java )to connect to mysql in windows *PLS provid the execution steps in detail THANK YOU
Expression Language execution in notepad
Expression Language execution in notepad  how to execute expression language in notepad for java i am using apache tomcat server4.0.
to know execution time
to know execution time  Hai this is sravanthi Is there any possibility to know the execution time of an SQL in its order to execute... to know the execution time for where,having and group by separately.If
different execution time - Java Beginners
different execution time    hello, when i run the bellow code more than one time i am getting different execution time("Total time taken"), Ex...));   Hi Friend, This problem is not due to any coding error or mistake
Java Batch Execution
is the result of the execution?  It returns the int array.The array... execution actually in JDBC Present a series of independent statements to be executed... or within a standard transaction. Execution of the batch is not all or nothing
execution of java program
execution of java program  wat are the steps for the execution of the servlet-jdbc program on tomcat 5.5 server.. PlS provide..the execution steps in detail..including the setting of classpath in DOS for mysql-connector-java. i
Execution of Multiple Threads in Java
Execution of Multiple Threads in Java  Can anyone tell me how multiple threads get executed in java??I mean to say that after having called the start method,the run is also invoked, right??Now in my main method if I want
servlets execution - JSP-Servlet
, To visit this link for solving the problem: http://www.roseindia.net/servlets
Beep in Execution - Java Beginners
for my "file reading" problem
How to stop the execution of midlet in j2me?
How to stop the execution of midlet in j2me?  Hi, How to stop the execution of midlet of j2me for a specific amount of time? Thanks & Regards, Sivakumar.J
java: try finally blocks execution
java: try finally blocks execution  java: try finally blocks execution
Java Execution Time Measurement(JETM)
Java Execution Time Measurement(JETM)  How can we integrate JETM in eclipse
Java Execution Time Measurement(JETM)
Java Execution Time Measurement(JETM)  Whether JETM can be implemented in Struts framework especially in Struts2. If not,tell the alternative solution
to know sql qyery execution time
to know sql qyery execution time  Hai this is sravanthi Is there any possibility to know the execution time of an SQL in its order to execute... possibility to know the execution time for where,having and group by separately.If
to know sql qyery execution time
to know sql qyery execution time  Hai this is sravanthi Is there any possibility to know the execution time of an SQL in its order to execute... possibility to know the execution time for where,having and group by separately.If
execution time calculation - JSP-Servlet
execution time calculation  I want to know how to find out execution time of an algorithm in java thread program.Pls send me an example of a thread program in which i can calculate the execution time of my program.  Hi
continuing execution after an exception is thrown
continuing execution after an exception is thrown  If while executing a statement in a try say the second statement, if it throws an exception, is it possible to handle that exception and then continue on with the remaining
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
thread is a sequential path of code execution within a program.
thread is a sequential path of code execution within a program.   thread is a sequential path of code execution within a program. what is the meaning if sequential path of code execution? please explain me
Advertisements
 

 

 

DMCA.com