








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A list of questions and answers related to Java programming. It covers topics such as object-oriented programming, encapsulation, data abstraction, polymorphism, inheritance, platform independence, memory management, performance, networking, and access modifiers. the concepts and provides examples of their implementation in Java. It is useful for students studying Java programming and preparing for exams or assignments.
Typology: Exams
1 / 14
This page cannot be seen from the preview
Don't miss anything!









object - Correct Answer ✅ capable of receiving messages, processing information or data, and sending messages to another/a class created at runtime Class - Correct Answer ✅ a blueprint which describes methods, functions, and constructors Encapsulation - Correct Answer ✅ wrapping data in a single unit Data Abstraction - Correct Answer ✅ hiding data; Hiding the irrelevant features and exposing only the needed features of a particular object Polymorphism - Correct Answer ✅ the same class name can have many different functions Inheritance - Correct Answer ✅ transferring the properties of one class to another Platform Independence - Correct 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 - Correct Answer ✅ Java is object-oriented, thus each program is built from objects and classes. Compiler/Interpreter - Correct 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 - Correct 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 - Correct Answer ✅ Memory management is automatically handled by Java Virtual Machine, which means the programmer does not need to write code to manage memory. Performance - Correct Answer ✅ Properly written Java programs execute quickly and use little memory. Networking - Correct Answer ✅ Java works on internet and intranet applications alike. Javadoc - Correct Answer ✅ To avoid mistakes and problems later as the program becomes longer and complex, you need to include comment
Private Protected These access modifiers are used with classes, methods, and variables. If - Correct Answer ✅ in the event that, i.e. If this occurs, that might happen. Then - Correct Answer ✅ at that time, i.e. I walked into the office and then went to sit down. Else - Correct Answer ✅ otherwise, i.e. You must do this or else go to bed. Switch - Correct Answer ✅ to shift from one to the other, i.e. Please switch places with me. While - Correct Answer ✅ a period of time marked by a condition, i.e. Stay here while I go see the doctor. Return - Correct Answer ✅ a statement which gives the output of the specific task. This will be used when you implement the conditional statement.
Public - Correct Answer ✅ accessible or shared by all members, i.e. I went into the public restroom. Static - Correct Answer ✅ not moving, i.e. The static content on the screen did not move. single line comment - Correct Answer ✅ //...... multi line comment - Correct Answer ✅ /..../ boolean - Correct Answer ✅ a one-bit value (one digit) represented true or false, 1 or 0 float - Correct Answer ✅ a 4-byte value that represents values from 1.40129846432481707 x 10-45 to 3. identifier - Correct 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 - Correct Answer ✅ As its name, an assignment operator assigns a value to a variable. An assignment operator is
&& operator - Correct 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 - Correct 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 1 0 1 0 1 1 0 0 0 Note: 1 represents true, 0 represents false
! operator - Correct Answer ✅! represents the logical operation NOT. In this type of operator the result is the opposite of the first operand. X Y X! 1 1 0 1 0 0 0 1 1 0 0 1 Note: 1 represents true, 0 represents false In this operation, if X is true then the resulting value will be false. This logical operator is used primarily to construct multiple conditional statements. bitwise operators - Correct Answer ✅ Anything and everything in the computer's memory is stored as a bit represented by 1s and 0s. So, the machine language of a computer is 1 and 0. It's that simple. Programmers use bitwise operators to manipulate these bits. & Exclusive AND ^ Exclusive OR | Inclusive OR compound operators - Correct Answer ✅ A Compound operator is a combination of arithmetical and assignment operators.
switch statement - Correct 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 - Correct 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 - Correct 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; increment/Decrement; } Do-While Statement - Correct Answer ✅ Do-while statements are different from the other iteration statements. Instead of checking the
Private Access Modifiers - Correct 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 - Correct 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];