SDT: Function and Array Practice Questions: Voting Scenario

Write pseudo code and source code (Java) for following scenario.

  • The number of different parties standing in the election. This must be a whole number between 2 and 10 inclusive.
  • Take the name of parties.
  • The number of votes cast for each party standing in the election. These must be whole numbers between 0 and 600,000 inclusive.
  • Display name of parties and their respective votes.

SDT-Topic-08

DDOOCP: Topic 02: Genesis and Structure of Java

static Modifiers

A variable or method that is shared by all instances of a class is called a class variable or class method.

Class variable or class method in Java is declared using static keyword.

A class variable/method can be referred either through anĀ instance of the class (like a normal instance variable) or through the full class name e.g. classname.variable or classname.method().

Some Important Questions

  1. Generate and display 20 random integers in the range 200 to 500.
  2. WAP to display following output.

Topic 2


DDOOCP: Topic 03: Introduction to Object Orientation

Simula was the first object-oriented programming language. Java, Python, C++, Visual Basic .NET and Ruby are the most popular OOP languages today. The Java programming language is designed especially for use in distributed applications on corporate networks and the Internet. Ruby is used in many Web applications.

From Wikipedia

Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A distinguishing feature of objects is that an object’s procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of “this“). that interact with one another. There is significant diversity in object-oriented programming, but most popular languages are class-based, meaning that objects are instances of classes, which typically also determines their type.

4 major principles of Object-Oriented Programming

  1. Encapsulation
  2. Abstraction
  3. Inheritance
  4. Polymorphism

Practice Questions

Topic-03

 

Related Slide


 

SDT: Function Practice Questions: Voting Scenario

Write pseudo code and source code (Java) for following scenario.

  • The amount of seats to be allocated. The amount of seats must be between 6 and 60 inclusive.
  • The number of different parties standing in the election. This must be a whole number between 2 and 10 inclusive
  • The number of votes cast for each party standing in the election. These must be whole numbers between 0 and 600,000 inclusive.

SDT-Topic-06