Task - Java Overview - Compilation and Execution of a Java Program #77
Replies: 15 comments
-
Beta Was this translation helpful? Give feedback.
-
Compilation with Multiple classInterpretation |
Beta Was this translation helpful? Give feedback.
-
FactorialMain.javaclass Factorial {
int calcFactorial(int n) {
int f = 1, i;
for (i = 1; i <= n; i++) {
f = f * i;
}
return f;
}
}
public class FactorialMain {
public static void main(String[] args) {
Factorial f = new Factorial();
System.out.println("Factorial of 5 is " + f.calcFactorial(5));
}
}Before compilationAfter compilationInterpretation |
Beta Was this translation helpful? Give feedback.
-
Compilation with multiple classesInterpretation |
Beta Was this translation helpful? Give feedback.
-
Compilation of Java File with multiple classExecution of main method |
Beta Was this translation helpful? Give feedback.
-
DEMONSTRATING THE EXECUTION OF A JAVA PROGRAMVehicleDemo.javaclass Car
{
static void run1()
{
System.out.println("CAR IS RUNNING");
}
}
class Bike
{
static void run2()
{
System.out.println("BIKE IS RUNNING");
}
}
class Bus
{
static void run3()
{
System.out.println("BUS IS RUNNING");
}
}
public class VehicleDemo
{
public static void main(String ar[])
{
Car.run1();
Bike.run2();
Bus.run3();
}
}OUTPUTCOMPILATIONINTERPRETATIONEXECUTION OF A JAVA PROGRAMFILESBEFORE COMPILATION-Java file is presentAFTER COMPILATION-Class files generated |
Beta Was this translation helpful? Give feedback.
-
Compilation and Executionclass MySample{
public static void method(){
System.out.println("Hello");
}
}
class Test{
public void service(){
System.out.println("Welcome all!");
}
}
class Example{
private void run(){
System.out.println("java program");
}
}
public class SampleProgm{
public static void main(String[] args) {
MySample.method();
System.out.println("Sample is compiled");
}
}OUTPUT:Before CompilationAfter CompilationInterpretationFiles |
Beta Was this translation helpful? Give feedback.
-
Shape.javaclass Rectangle{
static void display(){
System.out.println("Shape of the object is rectangle...");
}
}
class Triangle{
static void display1(){
System.out.println("Shape of the object is triangle...");
}
}
class Circle{
static void display2(){
System.out.println("Shape of the object is circle...");
}
}
public class Shape{
public static void main(String[] args){
System.out.println("Shapes...");
Rectangle.display();
Triangle.display1();
Circle.display2();
}
}Before CompilationAfter CompilationInterpretation |
Beta Was this translation helpful? Give feedback.
-
Before Compilation with multiple classAfter Compilation
Interpretation |
Beta Was this translation helpful? Give feedback.
-
CompilationInterpretation |
Beta Was this translation helpful? Give feedback.
-
CompilationInterpretation |
Beta Was this translation helpful? Give feedback.
-
Before CompilationAfter CompilationInterpretation |
Beta Was this translation helpful? Give feedback.
-
Compilation with multiple class:Interpretation: |
Beta Was this translation helpful? Give feedback.
-
Before CompilationAfter CompilationInterpretation |
Beta Was this translation helpful? Give feedback.
-
Before CompilationAfter CompilationInterpretation |
Beta Was this translation helpful? Give feedback.

































Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Create a Java program, such as HelloWorld.java, or any other simple Java program.
Demonstrate compiling the source code with the
javaccommand.Demonstrate executing the generated bytecode using the
javacommand.Bonus
Include multiple classes in a Java program file, and compile it. Run the program using the bytecode containing the
main()method.Beta Was this translation helpful? Give feedback.
All reactions