Task divided into three class they are: Super

Task AP1 Discuss the principles, characteristics and features of programming in JavaIt is a general programming language that is class based and object oriented.

It let programing developers write once and run anywhere. It enable developers to write computer introduction using computer based commands instead of writing in numerical code. It is also know as high level language. It has a set of rule that determines about how its written. The basic three principal of programming in java are as follow :Inheritance: It is a concept for code re usability.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!

order now

Inheritance is also divided into three class they are: Super Class: The class whose features are inherited is known as super class.Sub Class: The class that inherits the other class is known as sub class. The subclass can add its own fields and methods in addition to the superclass fields and methods.Reusability: Inheritance supports the concept of “reusability” that is when we want to create a new class and there is already a class that includes some of the code that we want we can derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class 2) Polymorphism: It means having many shapes or capacity to take on different forms. In java it describes a language ability to process object of various types and class. It have two types they are compile time polymorphism and run time polymorphism.3) Encapsulation: Encapsulation in Java is a mechanism of the data and code acting on the data together as a single unit.

The various of a class will be hidden from other classes, and can be accessed only through the methods of their current class. Therefore, it is also known as data hiding.Characteristics are :Java is Easy to write and more readable and eye catching.

Java has a cohesive set of features that makes it easy to learn and use.Most of the concepts are drew from C++ thus making Java learning simpler. Java program cannot harm other system thus making it secure.Java provides a secure means of creating Internet applications.Java provides secure way to access web applications.

Features are:* Simple:The Java language is easy to learn. Java code is easy to read and write. * Familiar:Java is similar to C/C++ but it removes the drawbacks and complexities of C/C++ like pointers and multiple inheritances. * Object-Oriented:Unlike C++ which is semi object-oriented, Java is a fully object-oriented programming language. It has all OOP features such as abstraction, encapsulation, inheritance and polymorphism.* Robust:With automatic garbage collection and simple memory management model, plus language features like generics.

Java guides programmer toward reliable programming habits for creating highly reliable applications. * Secure:The Java platform is designed with security features built into the language and runtime system such as static type-checking at compile time and runtime checking, which let you creating applications that can’t be invaded from outside. It is secure that it won’t effect from viruses attacking Java applications.

 * High Performance:Java code is compiled into byte code which is highly optimized by the Java compiler, so that the Java virtual machine can execute Java applications at full speed. * Multithreaded:The Java platform is designed with multithreading capabilities built into the language. That means we can build applications with many concurrent threads of activity, resulting in highly interactive and responsive applications.M1 Write an empty Constructor for class Instrument. Explain what a class Constructor is and define its main purpose. In your answer consider if a class can have more than one Constructor and if a subclass can inherit the Constructor/s. Show the syntax how the Constructor of child class ‘Student’ can use a Constructor of parent class ‘Person’I think it is not mandatory to have a default constructor in a class So, in that situation shall I have an empty constructor in the class Public class Instrument {Public Instrument () {}}A constructor in java is a block of code which is similar to the method that’s called when an instant of an object is created. A constructer allow to provide initial value for class field when creating an object.

They are chained and they are called in a particular order. It should not have return type. It is only executed one per object. There are three types of constructors: Default, Copy constructor and Parameterized.Default ConstructorParametrized ConstructorCopy ConstructorDefaultConstructorA constructor without any parameters is called a default constructor; in other words this type of constructor does not take parameters.

Parameterized Constructor  A constructor with at least one parameter is called a parametrized constructor. The advantage of a parametrized constructor is that you can initialize each instance of the class to different values.CopyConstructorThe constructor which creates an object by copying variables from another object is called a copy constructor. The purpose of a copy constructor is to initialize a new instance to the values of an existing instance.

P2 Highlight the differences between Override and Overload. Give examples (including syntax) of each.OVER RIDE Over loadIt occurs between two classes It occurs with the same classInheritance is involved Inheritance is not involvedChild method hide that of the parent class method. One method does not hide otherParameter must be same Parameter must be differentReturn type must be same Return type may or may not be same.Overloading : class Display Overloading{ public void disp(char c) { System.out.println(c); } public void disp(char c, int num) { System.out.

println(c + ” “+num); }Over rideclass Human{ //Overridden method public void eat() { System.out.println(“Human is eating”); }}class Boy extends Human{ //Overriding method public void eat(){ System.out.println(“Boy is eating”); } public static void main( String args) { Boy obj = new Boy(); //This will call the child class version of eat() obj.

eat();P4 Critically evaluate the use of JVM (Java Virtual Machine) of programming in JavaJVM stands for java virtual machine. It is platform dependent. It takes class files and execute by managing its memory. It also contain JIT.

It loads, verify and execute code and provide runtime environment. It also plays a vital role in java memory management. A Java virtual machine processes instructions similar to a physical processor. However, the Java code from a .JAVA file must first be converted into instructions the JVM can understand. This binary format, called byte code. It is the JVM responsibility that makes it possible for the same class file to run on any other Operating Systems. The JVM takes your compiled platform neutral byte code and helps it to run platform specific machine code.

It can also compile it into native code. Thus, it is in the JVM where code results, if needed, in native Operating System calls. Therefore, in the JVM, makes platform neutral threading code gets turned into platform-specific threading code. D1 Evaluate how such conclusions have been arrived at through synthesis of ideas and have been justified. You should include the advantages of having JVM for using Java in different environments.The Java Virtual Machine is an environment that executes Java programs. Java programs are compiled into an intermediate language called bytecode, which is that the JVM executes. Any program compiled into bytecode can be executed on any program that has a JVM installed on it.

This makes Java software compatible with many different computing operating system. The JVM has a few advantages that any developer should know:Platform IndependenceJava bytecode can be written once and then run on multiple platforms. Java bytecode does not need to be a specific hardware because it runs in the Java Virtual Machine. Any application compiled into Java bytecode can be run on any computing platform that has a Java Virtual Machine.SecurityJava was written with security in mind. The Java Virtual Machine has built-in security features that allow programmers to write highly secure Java programs.

It also prevents software from compromising the Operating System because it keeps Java applications from interacting with Operating System resources.PerformanceJava programs that run on a Java Virtual Machine tend to perform slower than programs written in C++. The system neutrality of bytecode acts as a disadvantage where performance is concerned.

This is because code optimization relies heavily on system-specific features. Since Java bytecode is system-neutral, it cannot be optimized for a specific hardware set.CorrectnessA program that performs, as expected, is said to be correct. Since a Java program relies on the Java Virtual Machine to execute it, the JVM must be free of errors for the program to operate correctly. This reliance on the Java Virtual Machine introduces a possible point of failure for the program.

Luckily, the Java Virtual Machine software is produced with very high standards, and therefore it isn’t likely to ship with any errors. Regardless, a failure in the Java Virtual Machine is a possibility that should be considered.P5 Identify a list of classes, attributes and methods from the above scenario.Classes Attributes MethodsPlayer Select Character TypeComputer Random Select characterPlayer comp AttackDefenseH.P=attackCharacter NameMagic PointHealth Point Get/Set Methods for 3 attributesWarriors SuperAttack NameDefense Move NameAttack Value Get/Set Methods for 3 attributesBlood elves Attack ValueHealing spellsuper Get/Set M3 Prepare an implementation of the classes with attributes and method identified above. – You do not need to prepare the syntax in each method.D2 Analyze in detail the role of each of the classes identified in P5 including reference to the chosen methods and attributes.

The role of the classes are as follow :A class defines where a Java program starts executing.b) A class is a graphical user interface component.c) A class is a specification of an object, through grouping variables and methods that define that object.d) A class is an instance of an object containing variables and methods.The role of method are as follow :The method is the entry point of you Java App. Whenever you execute a program, the main is the first function to be executed. You can call other functions from main to execute them.

In a standard app, there is one main function which uses other classes’ instances to function. When we write any code in Java, we know from where the main logic starts, from which statement should program execute /run .To let computer know from what point execution can start of your program the main method is designed.


I'm Casey!

Would you like to get a custom essay? How about receiving a customized one?

Check it out