Docsity

Java Programming Solved Questions and Answers, Exams of Biology

Toggle sidebar
bg1
JAVA Programming questions
fully solved 2025(graded A+)
object - answer capable of receiving messages, processing
information or data, and sending messages to another/a class
created at runtime
Class - answer a blueprint which describes methods, functions, and
constructors
Encapsulation - answer wrapping data in a single unit
Data Abstraction - answer hiding data; Hiding the irrelevant
features and exposing only the needed features of a particular
object
Polymorphism - answer the same class name can have many
different functions
Inheritance - answer transferring the properties of one class to
another
Platform Independence - answer Java's power comes from the ability
to compile code that can be read on any computer that has the Java
Virtual Machine installed.
Object-Oriented - answer Java is object-oriented, thus each program
is built from objects and classes.
Compiler/Interpreter - answer The Java compiler translates the
original code into bytecode so that any computer with JVM installed
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Java Programming Solved Questions and Answers and more Exams Biology in PDF only on Docsity!

JAVA Programming questions

fully solved 2025(graded A+)

object - answer capable of receiving messages, processing information or data, and sending messages to another/a class created at runtime Class - answer a blueprint which describes methods, functions, and constructors Encapsulation - answer wrapping data in a single unit Data Abstraction - answer hiding data; Hiding the irrelevant features and exposing only the needed features of a particular object Polymorphism - answer the same class name can have many different functions Inheritance - answer transferring the properties of one class to another Platform Independence - answer Java's power comes from the ability to compile code that can be read on any computer that has the Java Virtual Machine installed. Object-Oriented - answer Java is object-oriented, thus each program is built from objects and classes. Compiler/Interpreter - answer The Java compiler translates the original code into bytecode so that any computer with JVM installed

can run the compiled code, regardless of platform or operating system. Robust - answer Before executing a program, JVM conducts an overall checking of the program and gives reports of any malfunction.Thus, JVM is a robust programming language. Memory Management - answer Memory management is automatically handled by Java Virtual Machine, which means the programmer does not need to write code to manage memory. Performance - answer Properly written Java programs execute quickly and use little memory. Networking - answer Java works on internet and intranet applications alike. Javadoc - answer To avoid mistakes and problems later as the program becomes longer and complex, you need to include comment statements in your program to identify the program or section of code's purpose/this documentation of comments Comment Opener - answer /*** [line for comment] ***/ operators - answer ... iteration statements - answer Iteration statements repeat a function until a certain value or condition is satisfied. For Statement While Statement Do-While Statement

Public - answer accessible or shared by all members, i.e. I went into the public restroom. Static - answer not moving, i.e. The static content on the screen did not move. single line comment - answer //...... multi line comment - answer /..../ boolean - answer a one-bit value (one digit) represented true or false, 1 or 0 float - answer a 4-byte value that represents values from 1.40129846432481707 x 10-45 to 3. identifier - answer must start with a letter. It can be followed by a combination of numbers and two allowed special characters: underscore '_' and dollar sign '$'. When naming identifiers you need to be careful not to use any Java keywords. assignment operator - answer As its name, an assignment operator assigns a value to a variable. An assignment operator is represented by an equal sign. (X=5) With an assignment operator, Java runs the program from the right side to the left side. All other operators are evaluated from left to right. arithmetic operators - answer Addition + Subtraction - Multiplication * Division / Modulo Division %

relational operators - answer Greater Than > Less Than < Greater Than or Equal To >= Less Than or Equal To <= Equal To == Not Equal To != logical operators - answer These operators are used to evaluate two expressions. The evaluation stops as soon as the result is known. && AND || OR ! NOT && operator - answer This logical operator represents the logical operation AND in Java. This expression shows the result true if both its operands have the same value and false if not. X Y X&&Y 1 1 1 1 0 0 0 1 0 0 0 0 Note: 1 represents true, 0 represents false || operator - answer This operator represents the logical operation OR in Java. This expression shows the result false only if both its operands have the same value, and true even if one value is satisfied. X Y X||Y 1 1 1

conditional operators - answer [Condition]? [true statement] : [false statement]; selection statements - answer return true or false values. This means that until the condition is satisfied, the program will return true or false simple if condition - answer if (Condition) { //true block } if else statement - answer if (Condition) { //return true } else { //return false } switch statement - answer in Java you use Switch statements to control the flow of the program. Switch statements access a particular case when needed. Switch statement works with most of the data types such as byte, short, char, and int. switch (expression) { case cond1: code_block_1 ; break;

case cond2: code_block_2; break; ... case condn: code_block_n; break; default: code_block_default; break; } For Statement - answer When you want to control the number of times the condition has to be done, you want to create a loop. You use a for statement to create a loop. The for statement consists of the keyword for, followed by the three expressions in parenthesis separated by semicolons. These expressions are the initialization expression, test expression and the increment/decrement (re- initialization) expression. for (initialization; condition; increment/decrement) { //statement } While Statement - answer The While loop evaluates the condition first, and the execution starts only if the condition is found to be true. initialization; while (Condition) { Statement;

Private Access Modifiers - answer When a method or a variable is declared private, they are not accessible outside their class (by default all methods are private). A private class or method cannot be inherited and it cannot be used in an interface. To take full advantage of the object-oriented programming pillar of encapsulation, you should limit access as much as possible within the program. Syntax For method: [Access_Modifier] [Returntype] [Method_Name](args0, args1...argsn) { ................... } Syntax for variable: [Access_Modifier] [datatype] [variable] = [value]; protected access modifiers - answer A protected access modifier has the similar features to that of private access modifiers, except the method or variable in the class can be inherited. Syntax for Method: [Access_Modifier] [Returntype] [Method_Name](args0, args1...argsn) { ................... } Syntax for Variable: [Access_Modifier] [datatype] [variable] = [value];