1) What is the first step in problem-solving? A) Writing code B) Debugging C) Understanding the problem D) Optimizing the solution Answer: C 2) Which of these is not a step in the problem-solving process? A) Algorithm development B) Problem analysis C) Random guessing D) Testing and debugging Answer: C 3) What is an algorithm? A) A high-level programming language B) A step-by-step procedure to solve a problem C) A flowchart D) A data structure Answer: B 4) Which of these is the simplest data structure for representing a sequence of elements? A) Dictionary B) List C) Set D) Tuple Answer: B 5) What does a flowchart represent? A) Errors in a program B) A graphical representation of an algorithm C) The final solution to a problem D) A set of Python modules Answer: B 6) What is pseudocode? A) Code written in Python B) Fake code written for fun C) An informal high-level description of an algorithm D) A tool for testing code Answer: C 7) Which of the following tools is NOT commonly used in pr...
Define class in Java
In java, a class is a template used to create object and define the data type. It acts as a building block for java language oriented systems. All java codes are defined in a class. A class has variables and methods.
Variables are attributes which define the state of class.
Methods are the place where the exact business logic has to be done. It contains a set of statements or instructions to satisfy the particular requirement.
Eg:
public class Addition // class name declaration
{
int a= 5; // variable declaration
int b= 5;
public void add()
{ // Method declaration
int c=a+b;
}
}
What do you mean by object ?
Object is a basic unit of Object oriented programming and represents the real life entities. A typical java program creates many objects, which interact each other by invoking methods. A java object is a combination of data and procedures working on the available data. An object has a state and behavior. The state of an object is stored in fields(variables),while methods (functions) displays the object behavior. Objects are created from templates known as classes. In java an object is created by using the keyword 'new'.
What is immutable object ?
Immutable object are java object whose object cannot be modified once created. Any modification in immutable object result in new object. For example String is immutable in java. Mostly immutable are also final in java, inorder to prevent sub class from over ridding methods in java which can compromise immutability. You can achieve same functionality by making members as non final but private and not modifying them except in constructor.