Posts

Showing posts from November, 2022

Exercise - User definedClass-3

Image
TASK 1   Based on the following  UML class diagram :   a)               Write a complete Student class. b)               Next, write  TestStudent  class that invokes the methods of the  Student  class  and applies the concept of an array of objects. c)                Sample run as given below: User’s inputs    Matric No :  s1111   Test 1 :  67   Test 2 :  45   Matric No :  s2222   Test 1 :  67   Test 2 :  98   Matric No :  s3333   Test 1 :  67   Test 2 :  90   Program outputs   *****************************        STUDENT INFORMATION ***************************** Matric No   AverageMark   s1111   ...

Exercise - User definedClass-2

Image
Task 1 // The Triangle class stores and manipulates data for a //triangle.   public class Triangle {      private double height;      private double base;      // The setHeight method accepts an argument which is         //stored in the height field.      public void setHeight(double len)      {           height = len;      }      // The setBase method accepts an argument which is      //stored in the base field.          public void setBase(double b)      {           base = b;      }      //The set method accepts two arguments which are      //stored in the h...

Exercise - User definedClass-1

  1.            What will be the output from the following code?           class QuestionOne {      int count;      public void init(){            count = 1;      }      public void increment() {            count = count + 1; }      public int getCount() {            return count; } } public class Q1Main {      public static void main (String []arg) {            QuestionOne q1;            q1 = new QuestionOne();            System.out.println(q1.count);   ...