Docsity

Introduction to Java Programming: Exam Questions and Answers, Exams of Computer Science

Toggle sidebar
bg1
INTRO. TO JAVA PROGRAMMING
EXAM QUESTIONS AND VERIFIED
ANSWERS
Application Program Interface (API) - ANSWER Also called library, which
predefines classes and interfaces to develop Java programs
Assembler - ANSWER A program that converts assembly language into
machine language
Assembly Language - ANSWER A Low-Level language developed to simplify
writing code.
Bit - ANSWER The unit of measurement for information, 0 & 1 make up digits
known as the binary number system.
Block - Curly braces {}, each class has class blocking it group the data and
methods of the class.
Block Comment - /* Creates a block comment, computers will read the first /*
and ignore all text until the final */. (for multiply line instructions or comments)
Bus - Subsystem of computer components power and data flow through.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Introduction to Java Programming: Exam Questions and Answers and more Exams Computer Science in PDF only on Docsity!

INTRO. TO JAVA PROGRAMMING

EXAM QUESTIONS AND VERIFIED

ANSWERS

Application Program Interface (API) - ANSWER Also called library, which predefines classes and interfaces to develop Java programs Assembler - ANSWER A program that converts assembly language into machine language Assembly Language - ANSWER A Low-Level language developed to simplify writing code. Bit - ANSWER The unit of measurement for information, 0 & 1 make up digits known as the binary number system. Block - Curly braces {}, each class has class blocking it group the data and methods of the class. Block Comment - /* Creates a block comment, computers will read the first /* and ignore all text until the final */. (for multiply line instructions or comments) Bus - Subsystem of computer components power and data flow through.

Byte - ANSWER a sequence of 8 bits (enough to represent one character of alphanumeric data) processed as a single unit of information Bytecode - ANSWER Is similar to machine instructions but is architecture neutral and can run on any platform that has a JVM. Bytecode Verifier - ANSWER Checks the validity of the Bytecode and to make sure the Bytecode does not violate Java's security restrictions. Cable Modem - ANSWER Uses the cable TV line maintained by the cable company and is generally faster than DSL Central Processing Unit (CPU) - ANSWER The part of a computer (a microprocessor chip) that does most of the data processing. 2 parts; Control Unit and Arithmetic/LogicUnit. Class Loader - ANSWER A part of the Java Runtime Environment, it dynamically loads Java classes into the Java Virtual Machine. Usually classes are only loaded on demand. The Java run time system does not need to know about files and file systems because of class loaders. Comment - ANSWER Help programmers to communicate and understand the program. (//) single line comment. (/**/) multiply line comment Compiler - ANSWER A computer program, or set of programs, which translates source code written in a programming language into another computer language, typically having a binary form known as object code; this object code is usually generated for the particular computer architecture for which the program is intended. The most common reason for translating source code is to create an executable program.

Interpreter- ANS Translates the source code into machine code for execution. Java Command- ANS. Java Language Specification - ANSWER Is a technical definition of the syntax and semantics of the Java programming language. Java Virtual Machine (JVM) - ANSWER Iis a virtual machine capable of carrying out a program based on Java bytecode. It is the execution part of the code in the Java platform. Javac Command - ANSWER. Keyword (or reserved word) - ANSWER Have special meaning to the compiler and cannot be used for any other purpose in the program. Library - ANSWER Contains predefined classes and interfaces for developing Java programs. Line Comment - ANSWER // is used by programmers to relay information about coding in the program. Java Development Toolkit (JDK) - ANSWER The software for developing and running Java programs. Array - ANSWER a collection of a fixed number of components wherein all of the components have the same data type

How the components arranged in a one-dimensional array? - ANSWER In a list form index - ANSWER any expression whose value is a nonnegative integer The array index is always starts at. - ANSWER 0 Base address - ANSWER the address, or memory location, of the first array component T or F: A Method can return a value of the type array - ANSWER True T or F: A Method CANNOT return a value of the type array - ANSWER False T or F: The base address of an array is the address of the first array component - ANSWER True Algorithm - ANSWER A step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning. Assignment Operator (=) - ANSWER Is the operator used for assignment. Like most other other operators in C++, it can be overloaded.

programming languages. C-like languages became infamous for having two versions-pre- and post-of each operator with slightly different semantics. Double type - ANSWER A floating point data type that is usually more accurate than double precision. Like C's other floating point types it may not necessarily map to an IEEE format. Encoding - ANSWER Is a translation between formal languages. To programmers, the most familiar form of encoding is the compilation of a programming language into machine code or byte-code. Conversion between document formats are also forms of encoding. Compilation of TeX or LaTeX documents to PostScript are also commonly encountered encoding processes. Some high-level preprocessors such as OCaml's Camlp4 or Apple Computer's WorldScript also involve encoding of a programming language into another. Escape Character - ANSWER Is a character which invokes an alternative interpretation on subsequent characters in a character sequence. An escape character is a particular case of meta-characters. Generally, the judgement of whether something is an escape character or not depends on context. Expression-ANSWER A programming language is a combination of explicit values, constants, variables, operators and functions that are interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then produces-returns in a stateful environment-another value. This process, as for mathematical expressions is called evaluation. The value can be of various types, such as numerical, string and logical. Final Keyword - ANSWER Is used in several different contexts to define an entity which cannot later be changed.

Float Type - ANSWER A way of representing an approximation to a real number so that a very wide range of values can be represented. The numbers are, in general, represented approximately to a fixed number of significant digits (the mantissa) and scaled using an exponent. The base for the scaling is normally 2, 10 or 16. The typical number that can be represented exactly is of the form: Significant digits × base ^exponent Floating-Point Number - ANSWER Defines a method of representing an approximation of a real number in such a way that can also provide a very wide range of magnitudes. The numbers are, in general, represented approximately to a fixed number of significant digits, the mantissa and scaled using an exponent. The base for the scaling is usually 2, 10 or 16. Typical number that can be represented exactly is of the form: Identifier - ANSWER Are tokens, (also called symbols) which name language entities. Some of the kinds of entities an identifier might denote include variables, types, labels, subroutines, and packages. Increment Operator (++) - ANSWER Are unary operators that add or subtract one from their operand respectively. They are implemented in most imperative programming languages. C-like languages earned notoriety for implementing two versions each (preand post-) with slightly different semantics. Incremental Development and Testing - ANSWER Writing small portions of code-or very simple code, you could write the simplified shell of a program which is complex in theory, but simple and incremental-and then testing those incremental developments. Int Type - ANSWER A data type which represents some finite subset of the mathematical integers. Integral data types may be of different sizes and may or

than", with names often outside the language's set of identifiers for functions, and called with a syntax different from the language's syntax for calling functions. Common examples that differ by argument passing mode are boolean operations, e.g. a short-circuiting conjunction that only evaluates later arguments if earlier ones are not false, in a language with strict call-by-value functions. Overflow - ANSWER Occurs when an arithmetic operation attempts to create a numeric value that is too large to be represented within the available storage space. For example, adding 1 to the largest positive value that can be represented constitutes an integer overflow. The most common result in these cases is for the least significant representable bits of the result to be stored (the result is said to wrap). On some processors including GPUs and DSPs, saturation occurs; that is, once the maximum value is reached, attempts to make it larger simply return the maximum result. Postincrement -- Decrement - ANSWER Are unary operators that add or subtract one from their operand respectively. They are commonly implemented in imperative programming languages. C-like languages became notorious for featuring two versions of each (preand post-) with slightly different semantics. Postincrement - ANSWER Are unary operators that add or subtract one from their operand, respectively. They are commonly implemented in imperative programming languages. C-like languages became notorious for featuring two versions (pre- and post-) of each operator with slightly different semantics. Predecement - ANSWER Prefix derement, either ++i or --i i=sum of problem. Preincrement - ANSWER Prefix increment, either ++i or --i i=sum of problem. Primitive Data Type - ANSWER Is either of the following

  1. A basic type is a data type provided by a programming language as a basic building block. Most languages allow more complicated composite types to be recursively constructed starting from basic types.
  2. A built-in type is a data type for which the programming language provides built-in support. In most programming languages, all the basic data types are built-in. In addition, most languages also offer a set of composite data types. Pseudocode - ANSWER An informal high-level description of the operating principle of a computer program or other algorithm. Requirements Specification - ANSWER A requirements specification for a software system is a complete description of the behaviour of a system to be developed and may include a set of use cases describing the interactions the users will have with the software. In addition, it also contains non-functional requirements. Nonfunctional requirements impose constraints on the design or implementation such as performance engineering requirements, quality standards, or design constraints. Scope of a Variable - ANSWER Which parts of your program can see or use it. Normally, each variable has a global scope. Once defined, each part of your program can access a variable. Short Type - ANSWER Is a term for the abbreviations and slang commonly used with mobile phone text messaging, but sometimes used with other Internet- based communication such as email and instant messaging. Supplementary Unicode - ANSWER Those characters in the Unicode Character Standard that are outside of the Basic Multilingual Plane (BMP). The BMP comprises the first 64K characters in Unicode. The other characters are in the supplementary planes 1 to 16. Each plane is made up of 64K characters.

Unix time - ANSWER POSIX time describes a system to describe instant in time and defined as the number of seconds that have elapsed since 00:00: Coordinated Universal Time, Thursday, 1 January 1970, not counting leap seconds. Variable - ANSWER A storage location and an associated symbolic name (an identifier) which contains some known or unknown quantity or information, a value. The variable name is the usual way to reference the stored value; this separation of name and content allows the name to be used independently of the exact information it represents. Whitespace Character ANSWER A set of whitespace characters which in typography are interpreted as horizontal or vertical space. Rendered, a whitespace character usually does not correspond to a visible mark but generally occupies area on a page. For example, the general whitespace symbol, U+0020 space (HTML ), also ASCII 32, represents a blank used as a word divisor in Western scripts. Widening (of Types) - ANSWER Changes a value to a data type that can allow for any possible value of the original data. Widening conversions preserve the source value but can change its representation. This occurs if you convert from an integral type to Decimal, or from Char to String. Who is the comments for, the reader or the compiler? - ANSWER The Reader what are two kinds of comments? ANSWER Single Line & Multiple line what is entry point for running an application? - ANSWER Main what is a Java statement terminator? - ANSWER semicolon (;)

are keywords with programmatic definitions subject to re-definition? - ANSWER NO what is block? - ANSWER Pair of braces { } that groups things How would you display text in a message dialog box? ANSWER import javax.swing.JOptionPane; and call the showMessageDialog method What are syntax errors? ANSWER Those due to a violation of the rules of the programming language What are run time errors? ANSWER Those that cause the program to terminate or close prematurely. example: divide by 0, invalid input provided by the user What is a logic error? - ANSWER If the program does not work as anticipated. example: expect output to be 95, but get 60. Syntax - ANSWER rules that specify which statements (instructions) are legal Programming language - ANSWER a set of rules, symbols, and special words used to construct programs Semantic rule - ANSWER meaning of the instruction (means to print to the screen)

Import statements location - ANSWER After package and before class. Scanner input = new Scanner (system.in); - ANSWER allows the program to read inputs from the user import java.util.Scanner - ANSWER needed to use Scanner input = new Scanner (system.in); char - ANSWER single character: letter, digits and special symbols. examples: 'A', 'a', '0', '*', '+', ', '&' String - ANSWER a sequence of zero or more characters enclosed in double quotation marks (" ") Null - ANSWER a string with no characters How can a computer proceed? - ANSWER in Sequence Selectively (branch) - making a choice repetitively (iteratively) - looping Boolean type - ANSWER two values: true and false == - ANSWER Equal to ! - ANSWER not

&& - ANSWER and || - ANSWER or && (and) operator - ANSWER evaluates to true only when both operands evaluate to true otherwise it evaluates to false The || (Or) operator - ANSWER evaluates to true only when either operand evaluates to true otherwise it evaluates to false Use for loop - ANSWER If you know or can determine in advance the number of repetitions needed Use while loop - ANSWER If you do not know and cannot determine in advance the number of repetitions needed, and it could be zero Use do.while loop - ANSWER If you do not know and cannot determine in advance the number of repetitions needed, and it is at least one Nested control structure - ANSWER using a control structure within a control structure A while loop can be: - ANSWER Counter-controlled Sentinel-controlled Flag-controlled for loop - ANSWER simplifies the writing of a counter-controlled while loop

Return value type - ANSWER data type of the value the method returns; if the method doesn't return a value, the return type is void Method header - ANSWER lists modifiers, return type, method name, and parameters The return statement has the following form: - ANSWER return expr; When a return statement is executed - ANSWER Method terminates immediately Control returns to caller Execution always starts - ANSWER at the first statement in the method main Other methods are executed when. - ANSWER Only when they are called A method call causes - ANSWER control to pass to the first statement in the body of the called method When the last statement in a method has executed - ANSWER control is passed back to the point directly after the method call A value-returning method - ANSWER returns a value After the method is executed the returned value replaces the method call statement

Void method - ANSWER performs a desired operation without returning a value Local identifier - ANSWER identifiers declared within a method (or block) Global identifier - ANSWER identifiers declared outside of every method definition does Java allow nested methods? - ANSWER NO The scope of an identifier - ANSWER is the part of the program in which an identifier can be accessed Two kinds of user-defined methods - ANSWER value-returning methods and void methods Variables declared in a method header are known as - ANSWER Formal parameters Actual expressions, variables or constant values used in a method invocation are known as - ANSWER Actual parameters In a method call, the number and types of actual parameters must - ANSWER match the formal parameters in the order given To invoke a method - ANSWER use its name together with the actual parameter list