Question
How can I convert my Java classes to an executable .EXE file for Windows?
Answer
This is a very common question asked in the comp.lang.java newsgroup. Its often useful to have an executable application when deploying your applications to a specific platform, but remember to make your .class files available for users running Unix/Macintosh/other platforms.
Microsoft used to provide a free system development kit (SDK), for Java, which includes the jexegen tool.
This will convert class files into a .EXE form. The only disadvantage is that users need a Microsoft Java Virtual Machine (JVM) installed.
Microsoft no longer supports this however, and you should transition to a new Win 32 Java system.
See http://java.sun.com/ for the latest version of a Java interpreter for Winodws.
Though I've not used these tools personally, others have recommended Visual Age for Java, and
Duckware's Java to Windows EXE (Java2Exe) application available from http://www.duckware.com/java2exe/index.html
Showing posts with label Questions. Show all posts
Showing posts with label Questions. Show all posts
Thursday, February 12, 2009
Jad FAQ .....
FAQ
Q1: Is the source code of Jad available?
A1: Currently I have no plans to release the Jad source code for any purposes including porting to other computer platforms.
Q2: What is the option -dead for?
A2: This option forces Jad to decompile the dead portions of bytecode. For example, non-optimizing compilation of the following code can produce the dead bytecode: if (false)
{
...
}
This option should be on by default, but the incorrect dead bytecode can crash Jad.
Q3: Why does Jad fail to generate the throws clause in the method declarations like the one in int divide(int a, int b) throws DivideByZero { ... } ?
A3: This throws clause is represented in the Java class files by the Exceptions attribute. The Java Virtual Machine itself doesn't use these attributes (well, at least, the common implementations of JVM), so they can be stripped out of the Java class files. Jad has no way of restoring this information in full if it's missing from the class file.
Q4: Why does Jad generate weird-looking static fields like class$java$lang$Float and static methods class$(String)?
A4: These fields/methods are the internal representation of the.class expression and automatically generated by compiler. For example, java.lang.Thread.class is translated into the following: ...
((class$java$lang$Thread == null) ?
(class$java$lang$Thread = class$("java.lang.Thread")) :
class$java$lang$Thread);
...
static Class class$(String s)
{
try
{
return Class.forName(s);
}
catch(ClassNotFoundException ex)
{
throw new NoClassDefFoundError(ex.getMessage());
}
}
static Class class$java$lang$Thread;
This is fixed in 1.5.8. The explanation for the previous versions: Jad doesn't convert all that back to the original expression, but apparently the Sun JDK 1.2 compiler is able to compile "the long format" successfully. JDK 1.3 compiler doesn't accept names containing class$, so in order to recompile the decomplied class you need to change all expressions similar to the conditional expression above to.class and remove static methods/fields whose names start with class$.
Q5: Jad refuses to decompile my class file saying "Class file version mismatch". What can I do?
A5: Use -debug option. Jad then complains about the version mismatch, but attempts to decompile the file anyway. Note that this works starting from the version 1.5.6e.
Q6: Jad fails to decompile my class file, it spits out a bunch of gotos and JVM instructions. Why is that?
A6: There could be several possible reasons: the class file has been obfuscated or it was produced by non-JDK Java compiler or some functions were inlined by Java compiler. Generally Jad works best with class files generated by Sun Java compilers. If you encounter such a behaviour, please send me a bug report with attached .class files.
Q7: How to decompile jar or zip archive with classes?
A7: "Unjar" (jar xvf) or unzip (using unzip or WinZip) the archive into a directory on your hard drive. Then see the next answer.
Q8: How to decompile the whole class tree?
A8: Run jad -r [-d] [] **/*.class
On Unix the last argument should be in single quotes. For more information please read Readme.txt.
Q9: Why do I get "Class <>List not found" from the compiler?
A9: There are two List classes: java.awt.List and java.util.List. If Jad generates two import directives: import java.awt.*;
import java.util.*;
and your class actually uses the List class, the compiler will complain. Prior version 1.5.7d use the command-line option -pi to prevent Jad from combining the import directives.
Q10: How to make the command-line options -ff -nonlb -space -t to be on by default?
A10: Use the environment variable JAD_OPTIONS to permanently override the default settings. The example for Windows: set JAD_OPTIONS=-ff+ -nonlb+ -t+ -space+
Q11: How to extract Java classes from an executable file (.exe)?
A11: Use the Java-Split utility written by the Decafe Pro team. Download it from http://decafe.hypermart.net/javasplit.htm. Or use J++Extract from http://www.multimania.com/dolmen/productions.
Q12: What does the error message "JavaClassFileParseException: Invalid tag value 0x0" mean exactly?
A12: It means that your file is not a valid Java class and Jad was unable to parse it successfully. Either the file was broken (for example, during download) or the package this class belongs to contains a custom Java class loader that modifies (or decrypts) Java classes after reading them into the memory. In both cases Jad cannot decompile this file as it is.
Q1: Is the source code of Jad available?
A1: Currently I have no plans to release the Jad source code for any purposes including porting to other computer platforms.
Q2: What is the option -dead for?
A2: This option forces Jad to decompile the dead portions of bytecode. For example, non-optimizing compilation of the following code can produce the dead bytecode: if (false)
{
...
}
This option should be on by default, but the incorrect dead bytecode can crash Jad.
Q3: Why does Jad fail to generate the throws clause in the method declarations like the one in int divide(int a, int b) throws DivideByZero { ... } ?
A3: This throws clause is represented in the Java class files by the Exceptions attribute. The Java Virtual Machine itself doesn't use these attributes (well, at least, the common implementations of JVM), so they can be stripped out of the Java class files. Jad has no way of restoring this information in full if it's missing from the class file.
Q4: Why does Jad generate weird-looking static fields like class$java$lang$Float and static methods class$(String)?
A4: These fields/methods are the internal representation of the
((class$java$lang$Thread == null) ?
(class$java$lang$Thread = class$("java.lang.Thread")) :
class$java$lang$Thread);
...
static Class class$(String s)
{
try
{
return Class.forName(s);
}
catch(ClassNotFoundException ex)
{
throw new NoClassDefFoundError(ex.getMessage());
}
}
static Class class$java$lang$Thread;
This is fixed in 1.5.8. The explanation for the previous versions: Jad doesn't convert all that back to the original expression, but apparently the Sun JDK 1.2 compiler is able to compile "the long format" successfully. JDK 1.3 compiler doesn't accept names containing class$, so in order to recompile the decomplied class you need to change all expressions similar to the conditional expression above to
Q5: Jad refuses to decompile my class file saying "Class file version mismatch". What can I do?
A5: Use -debug option. Jad then complains about the version mismatch, but attempts to decompile the file anyway. Note that this works starting from the version 1.5.6e.
Q6: Jad fails to decompile my class file, it spits out a bunch of gotos and JVM instructions. Why is that?
A6: There could be several possible reasons: the class file has been obfuscated or it was produced by non-JDK Java compiler or some functions were inlined by Java compiler. Generally Jad works best with class files generated by Sun Java compilers. If you encounter such a behaviour, please send me a bug report with attached .class files.
Q7: How to decompile jar or zip archive with classes?
A7: "Unjar" (jar xvf
Q8: How to decompile the whole class tree?
A8: Run jad -r [-d
On Unix the last argument should be in single quotes. For more information please read Readme.txt.
Q9: Why do I get "Class <
A9: There are two List classes: java.awt.List and java.util.List. If Jad generates two import directives: import java.awt.*;
import java.util.*;
and your class actually uses the List class, the compiler will complain. Prior version 1.5.7d use the command-line option -pi to prevent Jad from combining the import directives.
Q10: How to make the command-line options -ff -nonlb -space -t to be on by default?
A10: Use the environment variable JAD_OPTIONS to permanently override the default settings. The example for Windows: set JAD_OPTIONS=-ff+ -nonlb+ -t+ -space+
Q11: How to extract Java classes from an executable file (.exe)?
A11: Use the Java-Split utility written by the Decafe Pro team. Download it from http://decafe.hypermart.net/javasplit.htm. Or use J++Extract from http://www.multimania.com/dolmen/productions.
Q12: What does the error message "JavaClassFileParseException: Invalid tag value 0x0" mean exactly?
A12: It means that your file is not a valid Java class and Jad was unable to parse it successfully. Either the file was broken (for example, during download) or the package this class belongs to contains a custom Java class loader that modifies (or decrypts) Java classes after reading them into the memory. In both cases Jad cannot decompile this file as it is.
Wednesday, February 11, 2009
100 Interview Questions
100 Java Technical Questions to Software Companies
1.what is polymorphism with example ? types of polymorphism?
2.what is final method & final variable with example?
3.How to deploy your struts application in JBOSS?
4.what exactly happens when we execute "Class.forname("Driver class name");"?Explain in detail
5.What are 5 common problems in the software development process?
6.What are the design patterns and How can they make life easier for software development ?
7.Design the Factory pattern and What is its application ?
8.What is impedance mismatch and How to solve the problem?
9.How can we design/implement singleton object
10.what is mean by overriding in which situation we will use?
11.How to create an instance of a class without using "new" operator?
12.How can we serialize a jsp page.
13.What are the benefits obtained by using the Client Server oriented TP Monitors Client Server applications?
14.What are the three types of SQL database server architecture?
15.what is servlet engineer?
16.what is the difference b/w design pattern and architecture?
17.In the HashMap, we know the values but we dont know the key, then how can we get the key from HashMap ?
18.What is the use of a form in html page? Is there any way to submit the page without using the form.
19.what is the difference between abstract class and Interface?where we can use it in realtime projects?
20.which class to use when concatenating strings in a loop.
21.explain System.out.println?
22.what is the difference between equals method and ==?
23.Iterator in the HashMap is fail-safe means ?
24.how to deploy apache tomcat server to weblogic server in java?
25.what is difference between method overloading & method overridding with example?
26.what is difference between perfom() & excute() ?
27.write a progam hashmap & hashtable?
28.Can java provide security ?
29.How to implement or use the singleton class in java?
30.What is the singleton class in java?
31.What is JIT ?
32.Is it possible to create Userdefined Unchecked Exception also? If Yes, give an example?
33.What is the need of "creating and throwing an UserdefinedException" when the "Exception" class is already available?
34.What is the difference between throw and throws? What is the similarity between try and throw?
35.Why operator overloading is not in Java?
36.Is Struts Action class Thread Safe?
37.what is webservices?
38.why java does not support multiple inheritance?
39.we cant Override Jsp Service method?Why?
40.What is the difference between sendRedirect() and forward()?
41.what s the difference b/w EJB 2.0 and EJB 3.0 technically?
42.what is ForwardAction and IncludeAction in struts?
43.Different types of threads?
44.what is features of jdk 1.5?
45.what is java bean?where can we use it?
46.what is jndi?
47.Diff between C++ and java?
48.what is an anonymous class?
49.what is the difference between pagecontext and servletcontext?
50.What is data abstraction? Elaborate with example?
51.Is ResultSet class?
52.whats the diff between jsp and servlets?
53.Differences between UNIQUE and DISTINCT in select statements?
54.Which is not Object in Java?
55.which method is used to know the status of the Thread?
56.what is data access layer?
57.Which Design Patterns you know?
58.what is MVC Pattern?
59.What is the difference between C++ & Java?
60.how session will be expired?
61.what is overloading in java?
62.What is serializable interface?
63.What is CardLayout?
64.How can we create object to a class in a jsp file?
65.which situation you use static include and dynamic include in jsp?
66.Difference between overloading and Overriding.
67.What is the exact difference in between Unicast and Multicast object ?
68.Which Math method is used to calculate the absolute value of a number?
69.What is meant by throwing an Exception?
.Write a program to know whether string is palindrome or not?
70 A C program is given and asked what will be output.............
71.A Recursive function is given asked what will be output how and why?
72.write a prg / function to remove the duplicate from a sorted array. (8 m)
5.write a prg to genrate fibonacci series upto 100 recursively. (7 m)
73.predict the output of the following:
char c[]={ " enter" , "first" , "print" , "new" }.;
char **cp[]={c+3, c+2, c+1, c};
char ***cpp[]=cp;
printf("%s", ++*cp);
printf("%s",--*++cp);
74.A program given and asked what are variables value1 and value2 stores?(ie, in that program they store GCD and LCM)
75.Write a program to sort linked list.
In a table their 20 records.I had update 6 records???How can see and retrieve particular 6 records
76.class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?
78.the control commands in the report program are
atfirst,atnew,atlast,atend of and what is the difference
between them
79.Difference between abstract class and interface
80.what's diff between struts 1.1 & 1.2?
81.can we have virtual functions in java?
82.what is Assertion?
83.Can we declare an anonymous class as both extending a class and implementing an interface?
84.What is hard code & soft code?
85.what is the difference between ArrayList and Vector?
86.How do you set security in applets?
87.what is an object and how do you allocate memory to it?
88.what is meant by string pooling?
89.Why Java is not purely object oriented?
90.What are other modifiers?
91.Can try statements be nested?
92.Can an exception be rethrown?
93.Name the class that used to read objects directly from a stream?
94.What Method and class used for Connection pooling ?
95.What are integer overflows and underflows and how to handle them?
96.How to eliminate duplicates from an array?
97.For which statements we use a label?
98.What is 3-tier model?
99.Difference between Application and Applet ?
100.Is there is any error if you have multiple main methods in the same class?
1.what is polymorphism with example ? types of polymorphism?
2.what is final method & final variable with example?
3.How to deploy your struts application in JBOSS?
4.what exactly happens when we execute "Class.forname("Driver class name");"?Explain in detail
5.What are 5 common problems in the software development process?
6.What are the design patterns and How can they make life easier for software development ?
7.Design the Factory pattern and What is its application ?
8.What is impedance mismatch and How to solve the problem?
9.How can we design/implement singleton object
10.what is mean by overriding in which situation we will use?
11.How to create an instance of a class without using "new" operator?
12.How can we serialize a jsp page.
13.What are the benefits obtained by using the Client Server oriented TP Monitors Client Server applications?
14.What are the three types of SQL database server architecture?
15.what is servlet engineer?
16.what is the difference b/w design pattern and architecture?
17.In the HashMap, we know the values but we dont know the key, then how can we get the key from HashMap ?
18.What is the use of a form in html page? Is there any way to submit the page without using the form.
19.what is the difference between abstract class and Interface?where we can use it in realtime projects?
20.which class to use when concatenating strings in a loop.
21.explain System.out.println?
22.what is the difference between equals method and ==?
23.Iterator in the HashMap is fail-safe means ?
24.how to deploy apache tomcat server to weblogic server in java?
25.what is difference between method overloading & method overridding with example?
26.what is difference between perfom() & excute() ?
27.write a progam hashmap & hashtable?
28.Can java provide security ?
29.How to implement or use the singleton class in java?
30.What is the singleton class in java?
31.What is JIT ?
32.Is it possible to create Userdefined Unchecked Exception also? If Yes, give an example?
33.What is the need of "creating and throwing an UserdefinedException" when the "Exception" class is already available?
34.What is the difference between throw and throws? What is the similarity between try and throw?
35.Why operator overloading is not in Java?
36.Is Struts Action class Thread Safe?
37.what is webservices?
38.why java does not support multiple inheritance?
39.we cant Override Jsp Service method?Why?
40.What is the difference between sendRedirect() and forward()?
41.what s the difference b/w EJB 2.0 and EJB 3.0 technically?
42.what is ForwardAction and IncludeAction in struts?
43.Different types of threads?
44.what is features of jdk 1.5?
45.what is java bean?where can we use it?
46.what is jndi?
47.Diff between C++ and java?
48.what is an anonymous class?
49.what is the difference between pagecontext and servletcontext?
50.What is data abstraction? Elaborate with example?
51.Is ResultSet class?
52.whats the diff between jsp and servlets?
53.Differences between UNIQUE and DISTINCT in select statements?
54.Which is not Object in Java?
55.which method is used to know the status of the Thread?
56.what is data access layer?
57.Which Design Patterns you know?
58.what is MVC Pattern?
59.What is the difference between C++ & Java?
60.how session will be expired?
61.what is overloading in java?
62.What is serializable interface?
63.What is CardLayout?
64.How can we create object to a class in a jsp file?
65.which situation you use static include and dynamic include in jsp?
66.Difference between overloading and Overriding.
67.What is the exact difference in between Unicast and Multicast object ?
68.Which Math method is used to calculate the absolute value of a number?
69.What is meant by throwing an Exception?
.Write a program to know whether string is palindrome or not?
70 A C program is given and asked what will be output.............
71.A Recursive function is given asked what will be output how and why?
72.write a prg / function to remove the duplicate from a sorted array. (8 m)
5.write a prg to genrate fibonacci series upto 100 recursively. (7 m)
73.predict the output of the following:
char c[]={ " enter" , "first" , "print" , "new" }.;
char **cp[]={c+3, c+2, c+1, c};
char ***cpp[]=cp;
printf("%s", ++*cp);
printf("%s",--*++cp);
74.A program given and asked what are variables value1 and value2 stores?(ie, in that program they store GCD and LCM)
75.Write a program to sort linked list.
In a table their 20 records.I had update 6 records???How can see and retrieve particular 6 records
76.class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?
78.the control commands in the report program are
atfirst,atnew,atlast,atend of and what is the difference
between them
79.Difference between abstract class and interface
80.what's diff between struts 1.1 & 1.2?
81.can we have virtual functions in java?
82.what is Assertion?
83.Can we declare an anonymous class as both extending a class and implementing an interface?
84.What is hard code & soft code?
85.what is the difference between ArrayList and Vector?
86.How do you set security in applets?
87.what is an object and how do you allocate memory to it?
88.what is meant by string pooling?
89.Why Java is not purely object oriented?
90.What are other modifiers?
91.Can try statements be nested?
92.Can an exception be rethrown?
93.Name the class that used to read objects directly from a stream?
94.What Method and class used for Connection pooling ?
95.What are integer overflows and underflows and how to handle them?
96.How to eliminate duplicates from an array?
97.For which statements we use a label?
98.What is 3-tier model?
99.Difference between Application and Applet ?
100.Is there is any error if you have multiple main methods in the same class?
Java Interview Questions
Java Interview Questions Frequently Asked Basic Questions
Q:
What is the difference between an Interface and an Abstract class?
A:
An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods..
Q:
What is the purpose of garbage collection in Java, and when is it used?
A:
The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.
Q:
Describe synchronization in respect to multithreading.
A:
With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.
Q:
Explain different way of using thread?
A:
The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, 'cause when you are going for multiple inheritance..the only interface can help.
Q:
What are pass by reference and passby value?
A:
Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.
Q:
What is HashMap and Map?
A:
Map is Interface and Hashmap is class that implements that.
Q:
Difference between HashMap and HashTable?
A:
The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.
Q:
Difference between Vector and ArrayList?
A:
Vector is synchronized whereas arraylist is not.
Q:
Difference between Swing and Awt?
A:
AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.
Q:
What is the difference between a constructor and a method?
A:
A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.
Q:
What is an Iterator?
A:
Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.
Q:
State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.
A:
public : Public class is visible in other packages, field is visible everywhere (class must be public too)private : Private variables or methods may be used only by an instance of the same class that declares the variable or method, A private feature may only be accessed by the class that owns the feature.protected : Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.This access is provided even to subclasses that reside in a different package from the class that owns the protected feature.default :What you get by default ie, without any access modifier (ie, public private or protected).It means that it is visible to all within a particular package.
Q:
What is an abstract class?
A:
Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such.A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.
Q:
What is static in java?
A:
Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can't override a static method with a nonstatic method. In other words, you can't change a static method into an instance method in a subclass.
Q:
What is final?
A:
A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).
Q:
What is the difference between an Interface and an Abstract class?
A:
An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods..
Q:
What is the purpose of garbage collection in Java, and when is it used?
A:
The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.
Q:
Describe synchronization in respect to multithreading.
A:
With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.
Q:
Explain different way of using thread?
A:
The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, 'cause when you are going for multiple inheritance..the only interface can help.
Q:
What are pass by reference and passby value?
A:
Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.
Q:
What is HashMap and Map?
A:
Map is Interface and Hashmap is class that implements that.
Q:
Difference between HashMap and HashTable?
A:
The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.
Q:
Difference between Vector and ArrayList?
A:
Vector is synchronized whereas arraylist is not.
Q:
Difference between Swing and Awt?
A:
AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.
Q:
What is the difference between a constructor and a method?
A:
A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.
Q:
What is an Iterator?
A:
Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.
Q:
State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.
A:
public : Public class is visible in other packages, field is visible everywhere (class must be public too)private : Private variables or methods may be used only by an instance of the same class that declares the variable or method, A private feature may only be accessed by the class that owns the feature.protected : Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.This access is provided even to subclasses that reside in a different package from the class that owns the protected feature.default :What you get by default ie, without any access modifier (ie, public private or protected).It means that it is visible to all within a particular package.
Q:
What is an abstract class?
A:
Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such.A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.
Q:
What is static in java?
A:
Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can't override a static method with a nonstatic method. In other words, you can't change a static method into an instance method in a subclass.
Q:
What is final?
A:
A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).
Subscribe to:
Posts (Atom)