JAVA
What are the public and private variables and methods?
It's important to understand the different between private and public variables and methods. When using the keyword private before a variable or a method, it means only the class itself can access the variable or method, when we're using public it means everybody can access it. We usually see constructors defined as public, variables defined as private and methods are separated, some public and some private.
What's JAVA technology?
JAVA technology is both a programming language and a platform.
What's the usage of the keyword "this"?
"this" is a keyword in Java which is used as a reference to the object of the current class, with in an instance method or a constructor. Using this you can refer the members of a class such as constructors, variables and methods. Note − The keyword this is used only within instance methods or constructors In general, the keyword this is used to − Differentiate the instance variables from local variables if they have same names, within a constructor or a method. class Student { int age; Student(int age) { this.age = age; } } Call one type of constructor (parametrized constructor or default) from other in a class. It is known as explicit constructor invocation. class Student { int age Student() { this(20); } Student(int age) { this.age = age; } }
How does the programs compile and run?
A .class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine. MyProgram.java -> compiler -> MyProgram.class -> Java VM 0100101...-> My Program Because the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris™ Operating System (Solaris OS), Linux, or Mac OS. Some virtual machines, such as the Java SE HotSpot at a Glance, perform additional steps at runtime to give your application a performance boost. This includes various tasks such as finding performance bottlenecks and recompiling (to native code) frequently used sections of code.
How do directories in JAVA work?
A directory is a File which can contain a list of other files and directories. You use File object to create directories, to list down files available in a directory. For complete detail, check a list of all the methods which you can call on File object and what are related to directories.
What's a platform?
A platform is the hardware or software environment in which a program runs. Some of the most popular ones are Microsoft Windows, Linux, Solaris OS, and Mac OS. Most platforms can be described as a combination of the operating system and underlying hardware.
What's a Stream?
A stream can be defined as a sequence of data. There are two kinds of Streams − − The InputStream is used to read data from a source. − The OutputStream is used for writing data to a destination. Source -> Program -> Destination Java provides strong but flexible support for I/O related to files and networks.
What's the difference between Abstract classes and Interfaces?
Abstract classes can contain fields which are not final and static and can contain implemented methods as well but interfaces cannot. Abstract classes with only abstract methods should be defined as interfaces. When an abstract class implements an interface not all interface methods need to be implemented, if the class is not abstract all the interface methods should be implemented. For example: abstract class X implements Y { // implements all but one method of Y } class XX extends X { // implements the remaining method in Y } Abstract classes can have static fields and static methods and works it would with normal classes.
How do you compile code?
After creating a simple application that prints something to the screen, you need to compile your code and run it. It shouldn't really matter if you use Linux, Mac or Windows. You need to have a console and you need to have the following commands available in order to compile and run Java. java (or java.exe) javac (or javac.exe) In order for those to be available you must download and install JDK (Java Development Kit). If we take the code from the previous lesson and put it in a file called MyFirstClass.java, in order to compile it we need to run: javac MyFirstClass.java This will create a file called MyFirstClass.class that holds the compiled java code. To run it, we need to run java with the name of the class as the argument (Not the file!) Wrong: java MyFirstClass.class Right!: java MyFirstClass
What are Standard Streams?
All the programming languages provide support for standard I/O where the user's program can take input from a keyboard and then produce an output on the computer screen. If you are aware of C or C++ programming languages, then you must be aware of three standard devices STDIN, STDOUT and STDERR. Similarly, Java provides the following three standard streams − Standard Input − This is used to feed the data to user's program and usually a keyboard is used as standard input stream and represented as System.in. Standard Output − This is used to output the data produced by the user's program and usually a computer screen is used for standard output stream and represented as System.out. Standard Error − This is used to output the error data produced by the user's program and usually a computer screen is used for standard error stream and represented as System.err.
What's an Abstract class?
An Abstract class is a class which has abstract keyword prefixed to it. A class must be prefixed with abstract if it has one or more methods with abstract keyword. An abstract method is only declared but not implemented. An abstract class cannot be instanciated but can be inherited by another class. The inheriting class must implement all the abstract methods or else the subclass should also be declared as abstract. For example: abstract class abstractClass { abstract void abstractMethod(); void concreteMethod() { // concrete methods are still allowed in abstract classes System.out.println("This is a concrete method."); } }
What are exceptions?
An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled. An exception can occur for many different reasons. Following are some scenarios where an exception occurs: - A user has entered an invalid data. - A file that needs to be opened cannot be found. - A network connection has been lost in the middle of communications or the JVM has run out of memory. Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner. Based on these, we have three categories of Exceptions. You need to understand them to know how exception handling works in Java. - Checked exceptions: A checked exception is an exception that occurs at the compile time, these are also called as compile time exceptions. These exceptions cannot simply be ignored at the time of compilation, the programmer should take care of (handle) these exceptions. - Unchecked exceptions: An unchecked exception is an exception that occurs at the time of execution. These are also called as Runtime Exceptions. These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation. - Errors: These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation.
What are some disadvantages of the JAVA platform?
As a platform-independent environment, the Java platform can be a bit slower than native code. However, advances in compiler and virtual machine technologies are bringing performance close to that of native code without threatening portability.
What are "Try and Catch"?
Before going into try/catch statements, let's talk about Exceptions. Exceptions are thrown every time an error occurs. Some examples: ArrayIndexOutOfBounds is thrown if the index that does not exist in an array is accessed (e.g: Trying to access arr[5], but arr only goes up to arr[4]) ArithmeticError is thrown if an illegal arithmetic operation is done (e.g: 42/0, division by zero) There are lots of exceptions that Java can throw (more than the above). But, how can you handle exceptions, when you're unsure if an error will occur. That's the purpose of try/catch! This is the syntax for try/catch: try { //Code here } catch (ExceptionHere name) { //Replace ExceptionHere with your exception and name with the name of your exception. //Code if exception "ExceptionHere" is thrown. } The code after the try block will be attempted to be run. If the exception in the catch statement is thrown during the code in the try block is run, run the code in the catch block. You can tell the user that there is a problem, or anything else. NOTE: You can also use Exception as the exception to catch if any exception is thrown.
How do Classes and Objects work in JAVA?
Everything in Java is within classes and objects. Java objects hold a state, state are variables which are saved together within an object, we call them fields or member variables. Let start with an example: class Point { int x; int y; } This class defined a point with x and y values. In order to create an instance of this class, we need to use the keyword new. Point p = new Point(); In this case, we used a default constructor (constructor that doesn't get arguments) to create a Point. All classes that don't explicitly define a constructor has a default constructor that does nothing.
How do the "implements" and "instanceof" keywords work?
Generally, the implements keyword is used with classes to inherit the properties of an interface. Interfaces can never be extended by a class. public interface Animal { } public class Mammal implements Animal { } public class Dog extends Mammal { } We can use the instanceof operator to check determine whether Mammal is actually an Animal, and dog is actually an Animal. interface Animal{} class Mammal implements Animal{} public class Dog extends Mammal { public static void main(String args[]) { Mammal m = new Mammal(); Dog d = new Dog(); System.out.println(m instanceof Animal); System.out.println(d instanceof Mammal); System.out.println(d instanceof Animal); } } This will print the word "true" three times.
How do you pass arguments to methods?
I always like to say that arguments to Java methods are passed by value, although some might disagree with my choice of words, I find it the best way to explain and understand how it works exactly. By value means that arguments are copied when the method runs. Let's look at an example. public void bar(int num1, int num2) { ... } This means that a value get copied to num1 and b value get copied to num2. Changing the values of num1 and num2 will not affect a and b. If the arguments were objects, the rules remain the same, but it acts a bit differently. Here is a an example: public void bar2(Student s1, Student s2) { ... } And here is how we use it Student joe = new Student("joe"); Student jack = new Student("jack"); bar2(joe, jack);
What is a "IS-A relationship"?
IS-A is a way of saying: This object is a type of that object. Let us see how the extends keyword is used to achieve inheritance. public class Animal { } public class Mammal extends Animal { } public class Reptile extends Animal { } public class Dog extends Mammal { } Now, based on the above example, in Object-Oriented terms, the following are true: - Animal is the superclass of Mammal class. - Animal is the superclass of Reptile class. - Mammal and Reptile are subclasses of Animal class. - Dog is the subclass of both Mammal and Animal classes. Now, if we consider the IS-A relationship, we can say − - Mammal IS-A Animal - Reptile IS-A Animal - Dog IS-A Mammal - Hence: Dog IS-A Animal as well With the use of the extends keyword, the subclasses will be able to inherit all the properties of the superclass except for the private properties of the superclass. We can assure that Mammal is actually an Animal with the use of the instance operator. For example: class Animal { } class Mammal extends Animal { } class Reptile extends Animal { } public class Dog extends Mammal { public static void main(String args[]) { Animal a = new Animal(); Mammal m = new Mammal(); Dog d = new Dog(); System.out.println(m instanceof Animal); System.out.println(d instanceof Mammal); System.out.println(d instanceof Animal); } } This will print the word "true" three times.
What are functions like in JAVA?
In JAVA functions are also called methods. A JAVA method is a collection of statements that are grouped together to perform an operation.In Java, all function definitions must be inside classes. Let's look at an example method. public class Main { public static void foo() { // Do something here } } foo is a method we defined in class Main. Notice a few things about foo. - static means this method belongs to the class Main and not to a specific instance of Main. Which means we can call the method from a different class like that Main.foo(). - void means this method doesn't return a value. Methods can return a single value in Java and it has to be defined in the method declaration. However, you can use return by itself to exit the method. - This method doesn't get any arguments, but of course Java methods can get arguments as we'll see further on.
How does inheritance work in JAVA?
In Java, the term inheritance refers to the adoption of all non-private properties and methods of one class (superclass) by another class (subclass). Inheritance is a way to make a copy of an existing class as the starting point for another. In addition to the term subclass, inherited classes are also called derived classes. At this point, it may be helpful to distinguish inheritance from interfaces. Interfaces define only the structure of the class members while inherited classes include the actual code of the superclass. Additionally, inheritance (more accurately, the definition of a subclass) uses the extends keyword in the subclass declaration. For clarity, if a subclass is created using a superclass and the subclass remains unaltered, the two classes will be identical. But most subclasses do not remain unaltered. Because a subclass is still a class, it can be altered to include new properties and methods. The finished subclass can even be used as a superclass to create additional subclasses. There is no effective limit to the number of inheritance levels. The methods and properties of a subclass can be used just like those of it's superclass. They can also be overridden. Overriding is the process of replacing (or augmenting) the original code with new code to suit the current purpose. An overridden method's signature in the subclass remains the same as the superclass but the contents of the method will be changed to meet the goal of the method in it's new form. This may even mean executing the code inherited from the superclass before or after executing some new code within the same method. To execute the inherited code from within the subclass, prefix the method with "super". It is also possible to write a subclass constructor that invokes the constructor of the superclass, either implicitly or by using the "super" keyword (e.g., super.methodName()). Why do this? Inheritance promotes code reuse and the concept of generic-to-specific implementation. Ideally, a superclass will be written at the most generic level. Subclasses can then be created from the superclass with a finer, more specific purpose.
What is Method Overriding?
In overriding, a method has the same method name, type, number of parameters, etc. It is different from overloading.
What's the extension for JAVA files?
In the Java programming language, all source code is first written in plain text files ending with the .java extension. Those source files are then compiled into .class files by the javac compiler.
What Integration Libraries does the JAVA platform provide?
Integration libraries such as the Java IDL API, JDBC API, Java Naming and Directory Interface (JNDI) API, Java RMI, and Java Remote Method Invocation over Internet Inter-ORB Protocol Technology (Java RMI-IIOP Technology) enable database access and manipulation of remote objects.
What are Interfaces?
Interfaces are class templates. Although not strictly required, they are part of the organizational structure of object-oriented programming. Interfaces define methods for classes by specifying the method name, the return type (or void) and the method arguments (by type and name). These method definitions are called signatures. Because this is a template, the method signatures contain no code. The code is entered into the implementation of an interface. Interfaces are used in the discipline of polymorphism. Note these two important points about interfaces: - If a class implements an interface, all of the interface's methods must appear in the class. - The implements keyword is used when creating a class that is modeled after an interface.
What's the "finalize( )" method?
It is possible to define a method that will be called just before an object's final destruction by the garbage collector. This method is called finalize( ), and it can be used to ensure that an object terminates cleanly. For example, you might use finalize( ) to make sure that an open file owned by that object is closed. To add a finalizer to a class, you simply define the finalize( ) method. The Java runtime calls that method whenever it is about to recycle an object of that class. Inside the finalize( ) method, you will specify those actions that must be performed before an object is destroyed. The finalize( ) method has this general form − protected void finalize( ) { // finalization code here } Here, the keyword protected is a specifier that prevents access to finalize( ) by code defined outside its class. This means that you cannot know when or even if finalize( ) will be executed. For example, if your program ends before garbage collection occurs, finalize( ) will not execute.
What are Character Streams?
Java Byte streams are used to perform input and output of 8-bit bytes, whereas Java Character streams are used to perform input and output for 16-bit unicode. Though there are many classes related to character streams but the most frequently used classes are, FileReader and FileWriter. Though internally FileReader uses FileInputStream and FileWriter uses FileOutputStream but here the major difference is that FileReader reads two bytes at a time and FileWriter writes two bytes at a time. Example: import java.io.*; public class CopyFile { public static void main(String args[]) throws IOException { FileReader in = null; FileWriter out = null; try { in = new FileReader("input.txt"); out = new FileWriter("output.txt"); int c; while ((c = in.read()) != -1) { out.write(c); } }finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } } Now let's have a file input.txt with the following content: This is test for copy file. As a next step, compile the above program and execute it, which will result in creating output.txt file with the same content as we have in input.txt. So let's put the above code in CopyFile.java file and do the following: $javac CopyFile.java $java CopyFile
What are Byte Streams?
Java byte streams are used to perform input and output of 8-bit bytes. Though there are many classes related to byte streams but the most frequently used classes are, FileInputStream and FileOutputStream. Following is an example which makes use of these two classes to copy an input file into an output file: import java.io.*; public class CopyFile { public static void main(String args[]) throws IOException { FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream("input.txt"); out = new FileOutputStream("output.txt"); int c; while ((c = in.read()) != -1) { out.write(c); } }finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } } Now let's have a file input.txt with the following content: This is test for copy file. As a next step, compile the above program and execute it, which will result in creating output.txt file with the same content as we have in input.txt. So let's put the above code in CopyFile.java file and do the following: $javac CopyFile.java $java CopyFile
How do non static methods work?
Non static methods in Java are used more than static methods. Those methods can only be run on objects and not on the whole class. Non static methods can access and alter the field of the object. public class Student { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } Calling the methods will require an object of type Student. Student s = new Student(); s.setName("Danielle"); String name = s.getName(); Student.setName("Bob"); // Will not work! Student.getName(); // Will not work!
What buzzwords describe the JAVA programming language?
Simple, Object oriented, Distributed, Multithreaded, Dynamic, Architecture neutral, Portable, High performance, Robust, Secure.
What are Command-Line Arguments?
Sometimes you will want to pass some information into a program when you run it. This is accomplished by passing command-line arguments to main( ). A command-line argument is the information that directly follows the program's name on the command line when it is executed. To access the command-line arguments inside a Java program is quite easy. They are stored as strings in the String array passed to main( ). The following program displays all of the command-line arguments that it is called with − public class CommandLine { public static void main(String args[]) { for(int i = 0; i<args.length; i++) { System.out.println("args[" + i + "]: " + args[i]); } } }
What's the Java Application Programming Interface or API?
The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces.
What does the API of the JAVA platform do?
The API provides the core functionality of the Java programming language. It offers a wide array of useful classes ready for use in your own applications. It spans everything from basic objects, to networking and security, to XML generation and database access, and more. The core API is very large; to get an overview of what it contains, consult the Java Platform Standard Edition 8 Documentation.
What Deployment Technologies does the JAVA platform provide?
The JDK software provides standard mechanisms such as the Java Web Start software and Java Plug-In software for deploying your applications to end users.
What's the JAVA Virtual Machine (JVM)?
The Java Virtual Machine or JVM is the base for the Java platform and is ported onto various hardware-based platforms.
How does the JAVA platform work?
The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms. The Java platform has two components: - The Java Virtual Machine - The Java Application Programming Interface (API) MyProgram.java -- API + JavaVM (aka Java platform) -- Hardware-Based Platform
How do variables work in JAVA?
The Java programming language uses both "fields" and "variables" as part of its terminology. Instance variables (non-static fields) are unique to each instance of a class. Class variables (static fields) are fields declared with the static modifier; there is exactly one copy of a class variable, regardless of how many times the class has been instantiated. Local variables store temporary state inside a method. Parameters are variables that provide extra information to a method; both local variables and parameters are always classified as "variables" (not "fields"). When naming your fields or variables, there are rules and conventions that you should (or must) follow.
What User Interface Toolkits does the JAVA platform provide?
The JavaFX, Swing, and Java 2D toolkits make it possible to create sophisticated Graphical User Interfaces (GUIs).
What Development Tools does the JAVA platform provide?
The development tools provide everything you'll need for compiling, running, monitoring, debugging, and documenting your applications. As a new developer, the main tools you'll be using are the javac compiler, the java launcher, and the javadoc documentation tool.
What can JAVA Technology do?
The general-purpose, high-level Java programming language is a powerful software platform. Every full implementation of the Java platform gives you the following features: - Development Tools - Application Programming Interface (API) - Deployment Technologies - User Interface Toolkits - Integration Libraries
What's the java.io package?
The java.io package contains nearly every class you might ever need to perform input and output (I/O) in Java. All these streams represent an input source and an output destination. The stream in the java.io package supports many data such as primitives, object, localized characters, etc.
How do arguments work?
The main methods get an array of strings as an argument, these are the command line arguments you may pass to your program. Every array in java holds a variable called length that says how many elements are within that array. We can go over the arguments with a simple for public class Arguments { public static void main(String[] args) { for (int i = 0; i < args.length; i++) { System.out.println(args[i]); } } } And to compile and run it with arguments: javac Arguments.java java Arguments arg0 arg1 arg2
How does the "super" keyword work?
The super keyword is similar to this keyword. Following are the scenarios where the super keyword is used. - It is used to differentiate the members of superclass from the members of subclass, if they have same names. - It is used to invoke the superclass constructor from subclass. If a class is inheriting the properties of another class, the subclass automatically acquires the default constructor of the superclass. But if you want to call a parameterized constructor of the superclass, you need to use the super keyword: super(values);
How do you create directories in JAVA?
There are two useful File utility methods, which can be used to create directories − - The mkdir( ) method creates a directory, returning true on success and false on failure. Failure indicates that the path specified in the File object already exists, or that the directory cannot be created because the entire path does not exist yet. - The mkdirs() method creates both a directory and all the parents of the directory. Following example creates "/tmp/user/java/bin" directory: import java.io.File; public class CreateDir { public static void main(String args[]) { String dirname = "/tmp/user/java/bin"; File d = new File(dirname); // Create directory now. d.mkdirs(); } } Note − Java automatically takes care of path separators on UNIX and Windows as per conventions. If you use a forward slash (/) on a Windows version of Java, the path will still resolve correctly.
What are the different types of inheritance?
There are various types of inheritance: - Single Inheritance: Class B -> Class A - Multi Level Inheritance: Class C -> Class B -> Class A - Hierarchical Inheritance: Class C, Class B -> Class A - Multiple Inheritance: Class C -> Class A, Class B NOTE: JAVA does not support multiple inheritance. This means that a class cannot extend more than one class.
What's a "HAS-A relationship"?
These relationships are mainly based on the usage. This determines whether a certain class HAS-A certain thing. This relationship helps to reduce duplication of code as well as bugs. Lets look into an example: public class Vehicle{} public class Speed{} public class Van extends Vehicle { private Speed sp; } This shows that class Van HAS-A Speed. By having a separate class for Speed, we do not have to put the entire code that belongs to speed inside the Van class, which makes it possible to reuse the Speed class in multiple applications. In Object-Oriented feature, the users do not need to bother about which object is doing the real work. To achieve this, the Van class hides the implementation details from the users of the Van class. So, basically what happens is the users would ask the Van class to do a certain action and the Van class will either do the work by itself or ask another class to perform the action.
What is "varargs" in JAVA?
Varargs can be defined as a method that is used to write more complex but very flexible methods that merely accept as many arguments as needed dynamically. Varargs are generally known in the Java world as Variable Argument. The limitations of arguments allowed by varargs can be single or multiple or zero. Prequel to varargs, there were either a method overloading or initializing an array that can take method parameters. Varargs always uses an internal mechanism called ellipsis which is generally a three dots after datatype as shown below: void percentage(String... a) { } Wherever varargs are used, developers must follow basic rules in order to compile the code effectively; else the code will not be complied and it will throw error. The rules are: A method should contain only one varargs strictly. In any cases, varargs should be the last argument. For Example, method_name(30,"Hi","Hello","varargs");
What is Method Overloading?
When a class has two or more methods by the same name but different parameters, it is known as method overloading. It is different from overriding. In overriding, a method has the same method name, type, number of parameters, etc.
What is a constructor?
You can have a default constructor (constructor that doesn't get arguments) to create instances of a class. All classes that don't explicitly define a constructor has a default constructor that does nothing. We can define our own constructor: class Point { int x; int y; Point(int x, int y) { this.x = x; this.y = y; } } This means we can not longer use the default constructor new Point(). We can now only use the defined constructor new Point(4, 1). We can define more than one constructor, so Point can be created in several ways. Let's define the default constructor again. class Point { int x; int y; Point() { this(0, 0); } Point(int x, int y) { this.x = x; this.y = y; } } Notice the usage of the this keyword here. We can use it within a constructor to call a different constructor (in order to avoid code duplication). It can only be the first line within the constructor.
How do you list directories in JAVA?
You can use list( ) method provided by File object to list down all the files and directories available in a directory as follows: import java.io.File; public class ReadDir { public static void main(String[] args) { File file = null; String[] paths; try { // create new file object file = new File("/tmp"); // array of files and directory paths = file.list(); // for each name in the path array for(String path:paths) { // prints filename and directory name System.out.println(path); } }catch(Exception e) { // if any error occurs e.printStackTrace(); } } } This will produce the following result based on the directories and files available in your /tmp directory: test1.txt test2.txt ReadDir.java ReadDir.class
How does the "extends" keyword work?
extends is the keyword used to inherit the properties of a class. Following is the syntax of extends keyword. class Super { ..... } class Sub extends Super { ..... } Following is an example demonstrating Java inheritance. In this example, you can observe two classes namely Calculation and My_Calculation. Using extends keyword, the My_Calculation inherits the methods addition() and Subtraction() of Calculation class. class Calculation { int z; public void addition(int x, int y) { z = x + y; System.out.println("The sum of the given numbers:"+z); } public void Subtraction(int x, int y) { z = x - y; System.out.println("The difference between the given numbers:"+z); } } public class My_Calculation extends Calculation { public void multiplication(int x, int y) { z = x * y; System.out.println("The product of the given numbers:"+z); } public static void main(String args[]) { int a = 20, b = 10; My_Calculation demo = new My_Calculation(); demo.addition(a, b); demo.Subtraction(a, b); demo.multiplication(a, b); } } In the given program, when an object to My_Calculation class is created, a copy of the contents of the superclass is made within it. That is why, using the object of the subclass you can access the members of a superclass. The Superclass reference variable can hold the subclass object, but using that variable you can access only the members of the superclass, so to access the members of both classes it is recommended to always create reference variable to the subclass. If you consider the above program, you can instantiate the class as given below. But using the superclass reference variable ( cal in this case) you cannot call the method multiplication(), which belongs to the subclass My_Calculation. Note − A subclass inherits all the members (fields, methods, and nested classes) from its superclass. Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass.
What's the Hello World like in JAVA?
public class HelloWorldApp { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Hello World!"); // D } }