Java
Programming and Technical
Programming
Technical
What if I write static public void instead of public static void?
Read Solution (Total 23)
-
- First of all, v cannot declare a class as "private"...
The only allowed modifiers are class without modifier(no modifier) and public...
- 10 years agoHelpfull: Yes(19) No(4)
- once we declare class as private we cannot create sub class
- 10 years agoHelpfull: Yes(4) No(0)
- It's absolutely fine....the program will compile n run. Because JVM isn't concerned about sequence of keywords as far as they are present in the main statement.
- 9 years agoHelpfull: Yes(4) No(0)
- yes because that subclass contains some of the properties of super class and we can still use that sub class and can define as public. If we dont do that then we can never use the resources of those classes.
- 10 years agoHelpfull: Yes(3) No(2)
- package com.javapapers.sample;
class Light {
private void glow() {
System.out.println("Glow glow");
}
}
class SunLight extends Light {
public void glow() {
System.out.println("Call me in your day time!");
}
}
public class SubclassPrivateExample {
public static void main(String args[]) {
SunLight sL = new SunLight();
sL.glow();
}
}
run it n will see that the answer will be yes - 9 years agoHelpfull: Yes(3) No(0)
- with class only public,abstract and final is permitted!!!
- 10 years agoHelpfull: Yes(2) No(0)
- yes we can define, but can not use the properties of its superclass
- 9 years agoHelpfull: Yes(1) No(0)
- both are same
- 9 years agoHelpfull: Yes(1) No(0)
- yes because public and static are modifiers we can write any way either public static void or static public void
- 7 years agoHelpfull: Yes(1) No(0)
- no class should be private
only allowed are public or default - 10 years agoHelpfull: Yes(0) No(0)
- no
because private class will be work only in that perticular class
- 10 years agoHelpfull: Yes(0) No(1)
- no we cannot
- 10 years agoHelpfull: Yes(0) No(1)
- In java default specifier is default so subclass of private class can be public.
- 10 years agoHelpfull: Yes(0) No(0)
- At the top level—public, or package-private (no explicit modifier).
At the member level—public, private, protected, or package-private (no explicit modifier).
A class may be declared with the modifier public, in which case that class is visible to all classes everywhere. If a class has no modifier (the default, also known as package-private), it is visible only within its own package (packages are named groups of related classes — you will learn about them in a later lesson.)
At the member level, you can also use the public modifier or no modifier (package-private) just as with top-level classes, and with the same meaning. For members, there are two additional access modifiers: private and protected. The private modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package. - 10 years agoHelpfull: Yes(0) No(0)
- we cant declare class not private nor protected...the class can be declare with only public and default access modifier..
- 10 years agoHelpfull: Yes(0) No(0)
- program compiles and runs properly
- 9 years agoHelpfull: Yes(0) No(0)
- program compile and execute successfully no essue.
- 9 years agoHelpfull: Yes(0) No(0)
- it will not display any error and program will run
- 9 years agoHelpfull: Yes(0) No(0)
- No error at all
- 9 years agoHelpfull: Yes(0) No(0)
- It will not the meaning of line instead we write as above.
- 9 years agoHelpfull: Yes(0) No(0)
- not a prob at all...........since both are modifiers ...v can change the order ...!!
- 9 years agoHelpfull: Yes(0) No(0)
- it wont affect the meaning of it
- 8 years agoHelpfull: Yes(0) No(0)
- yes,we can write the program will execute..even if we change the order..
- 7 years agoHelpfull: Yes(0) No(0)
Java Other Question