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

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

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
execution
execution
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
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
Version of com.automationrockstars>execution dependency
List of Version of com.automationrockstars>execution dependency
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
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
Struts-problem With DispatchAction Class
Struts-problem With DispatchAction Class  hi this is Mahesh...i'm...: Servlet execution threw an exception root cause java.lang.NoClassDefFoundError: org/apache/struts/actions/DispatchAction Can any one help me with this problem
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
ModuleNotFoundError: No module named 'execution-asserts'
ModuleNotFoundError: No module named 'execution-asserts'  Hi, My... named 'execution-asserts' How to remove the ModuleNotFoundError: No module named 'execution-asserts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'execution-pipeline'
ModuleNotFoundError: No module named 'execution-pipeline'  Hi, My... named 'execution-pipeline' How to remove the ModuleNotFoundError: No module named 'execution-pipeline' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Execution-Time'
ModuleNotFoundError: No module named 'Execution-Time'  Hi, My... named 'Execution-Time' How to remove the ModuleNotFoundError: No module named 'Execution-Time' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'execution-trace'
ModuleNotFoundError: No module named 'execution-trace'  Hi, My... named 'execution-trace' How to remove the ModuleNotFoundError: No module named 'execution-trace' error? Thanks   Hi, In your python
Version of com.twitter>execution-tutorial_2.10 dependency
List of Version of com.twitter>execution-tutorial_2.10 dependency
Version of com.twitter>execution-tutorial_2.11 dependency
List of Version of com.twitter>execution-tutorial_2.11 dependency
Version of com.twitter>execution-tutorial_2.12 dependency
List of Version of com.twitter>execution-tutorial_2.12 dependency
Beep in Execution - Java Beginners
for my "file reading" problem
servlets execution - JSP-Servlet
, To visit this link for solving the problem: http://www.roseindia.net/servlets
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.JADS_TO_REPLACE_1
Java Execution Time Measurement(JETM)
Java Execution Time Measurement(JETM)  How can we integrate JETM in eclipse
java: try finally blocks execution
java: try finally blocks execution  java: try finally blocks execution
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
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, likeADS_TO_REPLACE_1 thanks n regards himanshu
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem
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
problem on strings
problem on strings  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic for this with out using StringBuffer concept. Thanks in advanace
Problem with loginbean.jsp
Problem with loginbean.jsp  http://www.roseindia.net/jsp/loginbean.shtml - I am getting an error in loginbean.jsp.There is some error regarding .What is hello in this? Also in this example how
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
Problem with cookies
Problem with cookies  Hello All, i need jsp code for RememberMe module of login. i am facing problem with cookies. so please if any one could guide me please help and provide mme the exact code.   Please visit
problem with package
problem with package  Dear sir, i have created one java file with package com.net; and i compiled the program.it showing the .class file in " net" folder.The problem is i want to use that .class file in some other
Oracle9i Problem
Oracle9i Problem  Hi I have a problem in Oracle9i .I have... the table what i created .But after closing the SQL+ ,the problem started.When i... .....;.it is saying no rows are selected.Why the problem arised in not getting the data that i
problem with session.invalidate()
problem with session.invalidate()  i stuck by a line with "session.invalidate()", after user logout also by pressing the back button of the browser user is still able to navigate to his home page and able to view the session
JScrollBar Problem...
JScrollBar Problem...  Hello Sir/mam, Can i know how to use JScrollBar to JFrame without adding any JPanel to it.. i want to add JScrollBar Directly to JFrame... Please Provide me Simple Example so i can understand
problem on php
problem on php   l have five tables and build them as forms and link between them php and database and i want to build query between them plz help me soon   PHP MySQL Tutorials
URL problem
URL problem  Hi. I have created a webpage for my project website. in that i have used frameset to split the page. Now if i click any link in the page its navigating to the another page. but the problem is here in the url its
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
struts---problem with DispatchAction
struts---problem with DispatchAction  hi this is Mahesh...i'm working... error: exception javax.servlet.ServletException: Servlet execution threw.../DispatchAction Can any one help me with this problem.... Thanks in Advance
Is AI a problem?
Is AI a problem?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Is AI a problem? Try... "Is AI a problem?". Also tell me which is the good training courses
Skyline Problem
is the line tracing the largest y value from any rectangle in S The Problem: Write.... Your method should solve the problem three different ways; each solution
Problem in Array
Problem in Array  Hi, Can you help me with this problem? Run a program that check if the input string contains equal number of A's and B's. Hoping for your answer.Thank you.   Here is an example that check

Ads