write a program in java to create a class Convert to declare and initialise variable time with value 450.
Print the entered time in minutes: seconds format
Answers
Answer:
Java basics
last modified July 6, 2020
In this part of the Java tutorial, we cover some basic programming concepts of the Java language. We begin with some simple programs. We work with variables, constants, and basic data types. We read and write to console and we also mention string formatting.
Java simple example
We start with a very simple code example. The following code is placed into the Simple.java file. The naming is important here. A public class of a Java program must match the name of the file.
com/zetcode/Simple.java
package com.zetcode;
public class Simple {
public static void main(String[] args) {
System.out.println("This is Java");
}
}
Java code is strictly organized from the very beginning. A file of a Java code may have one or more classes, out of which only one can be declared public.
package com.zetcode;
Packages are used to organize Java classes into groups, which usually share similar functionality. Packages are similar to namespaces and modules in other programming languages. For a simple code example, a package declaration may be omitted. This will create a so called default package. However, in this tutorial we will use a package for all examples. Another important thing is that a directory structure must reflect the package name. In our case the source file Simple.java with a package com.zetcode must be placed into a directory named com/zetcode/. The package statement must be the first line in the source file.