Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Question about protected access

  Asked By: Pedro    Date: Apr 06    Category: Java    Views: 630
  

Q1. How does 'java' find API classes installed in the system?

Q2. I experimentally made a class with default (package) access and put it into
a package. Then made another class with package access and with a main method
tried to run it.
The latter class also belonged to the same package as the previous one and it
used previous class to make one object. However, my attempt was unsuccesful.
What could be the fault?

Since main method is a public one should I make SecondOne class public too, or
is it that I can't run a class within the package itself?

Pl. help.

package myjava.java2;
class FirstOne {
int a=10;
int b=5;
int intMultiply() {
return a*b;
}
}

package myjava.java2;
class SecondOne {
public static void main(String[] args) {
FirstOne fo=new FirstOne();
System.out.println(fo.intMultiply());
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Question about protected access Or get search suggestion and latest updates.




Tagged: