Docsity

COMP 308 JAVA FOR PROGRAMMERS COMPREHENSIVE QUESTIONS AND CORRECT ANSWERS, Exams of Data Representation and Algorithm Design

Toggle sidebar
bg1
COMP 308 JAVA FOR PROGRAMMERS
COMPREHENSIVE QUESTIONS AND CORRECT
ANSWERS
โ—‰ What is a CPU?
Answer: The Central Processing Unit (CPU) is the brain of the
computer. It retrieves instructions from memory and executes them.
โ—‰ What is memory?
Answer: Memory stores data and program instructions that are sent
to the CPU for execution.
โ—‰ How does a computer work?
Answer: Input is entered, data and instructions are placed in
memory, the CPU processes them, and the result is sent to an output
device.
โ—‰ What is monitor resolution?
Answer: The number of pixels used to form the display. Higher
resolution generally makes images sharper and clearer.
โ—‰ What is a pixel?
pf3
pf4
pf5
pf8

Partial preview of the text

Download COMP 308 JAVA FOR PROGRAMMERS COMPREHENSIVE QUESTIONS AND CORRECT ANSWERS and more Exams Data Representation and Algorithm Design in PDF only on Docsity!

COMP 308 JAVA FOR PROGRAMMERS

COMPREHENSIVE QUESTIONS AND CORRECT

ANSWERS

โ—‰ What is a CPU? Answer: The Central Processing Unit (CPU) is the brain of the computer. It retrieves instructions from memory and executes them. โ—‰ What is memory? Answer: Memory stores data and program instructions that are sent to the CPU for execution. โ—‰ How does a computer work? Answer: Input is entered, data and instructions are placed in memory, the CPU processes them, and the result is sent to an output device. โ—‰ What is monitor resolution? Answer: The number of pixels used to form the display. Higher resolution generally makes images sharper and clearer. โ—‰ What is a pixel?

Answer: A tiny picture element, or dot, that forms part of an image on the screen. โ—‰ What is a software program? Answer: A set of instructions that tells a computer what to do. โ—‰ What is a programming language? Answer: A language used to write instructions that communicate with a computer. โ—‰ What are the 3 categories of programming languages? Answer: Machine language, assembly language, and high-level language. โ—‰ What is machine language? Answer: A set of primitive computer instructions written in binary code using 0s and 1s. โ—‰ What is assembly language? Answer: A programming language that uses symbolic instructions and must be translated into machine code by an assembler. โ—‰ What is a high-level language?

Answer: Java is simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high-performing, multithreaded, and dynamic. โ—‰ What does 'write once, run anywhere' mean in Java? Answer: Java bytecode can run on any platform that has a Java Virtual Machine (JVM). โ—‰ What is object-oriented programming (OOP)? Answer: A programming approach that organizes programs around objects and keeps data together with the operations that work on that data. โ—‰ What is the difference between traditional programming and OOP? Answer: Traditional programming keeps data and behavior separate. OOP keeps data and behavior together in classes and objects. โ—‰ What fruit-basket example explains OOP? Answer: Traditional: fruit and knives are kept separately. OOP: each fruit is grouped with the correct knife, meaning data and operations are kept together.

โ—‰ What car example explains traditional programming vs. OOP? Answer: Manual transmission represents the traditional approach because the driver changes gears. Automatic transmission represents OOP because the gear-changing operation is built into the car. โ—‰ What is Java bytecode? Answer: The special object code created when Java source code is compiled. โ—‰ What is the Java Virtual Machine (JVM)? Answer: Software that interprets and runs Java bytecode. โ—‰ What is the Java execution process? Answer: Java Source Code โ†’ Compiler โ†’ Bytecode โ†’ JVM โ†’ Computer. โ—‰ What are the 3 types of Java comments? Answer: Line comments, paragraph comments, and javadoc comments. โ—‰ How do you write a Java line comment? Answer: // comment

โ—‰ Give examples of Java modifiers. Answer: public, static, private, final, abstract, and protected. โ—‰ What is a Java statement? Answer: A direct instruction that tells the computer to perform an action or sequence of actions. โ—‰ What normally ends a Java statement? Answer: A semicolon (;). โ—‰ Give an example of a Java statement. Answer: System.out.println("Welcome to Java!"); โ—‰ What is a Java class? Answer: A template or blueprint for objects. A Java program is defined using one or more classes. โ—‰ Give an example of a Java class header. Answer: public class Test โ—‰ What is a Java method?

Answer: A collection of statements that performs a sequence of operations. โ—‰ What is the main() method? Answer: The method that controls program flow and is where Java begins executing an application. โ—‰ What is an example of a method call? Answer: System.out.println("Welcome to Java!"); โ—‰ What is an argument in a method call? Answer: A value passed inside the parentheses of a method call, such as a string to be printed. โ—‰ Write a Java program that prints 'This is our first program'. Answer: public class FirstProgram { public static void main(String[] args) { System.out.println("This is our first program"); } } โ—‰