0% found this document useful (0 votes)
3 views3 pages

CH 3-4 Answers

The document contains an answer key for a programming assessment, covering topics such as object-oriented programming, data types, and Java syntax. It includes fill-in-the-blank questions, true or false statements, multiple-choice questions, and code examples. The answers provide insights into fundamental programming concepts and Java operations.

Uploaded by

saptarshirina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

CH 3-4 Answers

The document contains an answer key for a programming assessment, covering topics such as object-oriented programming, data types, and Java syntax. It includes fill-in-the-blank questions, true or false statements, multiple-choice questions, and code examples. The answers provide insights into fundamental programming concepts and Java operations.

Uploaded by

saptarshirina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

✅ Answer Key

Section A

Q1. Fill in the blanks:​


a) Encapsulation​
b) byte​
c) String​
d) statically​
e) boolean

Q2. True or False:​


a) True​
b) False​
c) False​
d) False​
e) True

Q3. One line answers:​


a) A class is a blueprint or template for creating objects.​
b) Primitive data types are the basic data types like int, char, boolean, etc.​
c) ++a or --a​
d) Inheritance, Encapsulation​
e) false

Q4. Differences:​
(Examples)​
a) Class is a template; Object is an instance of a class.​
b) Primitive stores actual value; Non-primitive stores references.​
c) Integer: 5, -10; Float: 3.14, -2.0f​
d) Implicit is automatic; Explicit is manual casting

Q5. Outputs:​
a) 20​
b) true​
c) 8

Q6. MCQs:​
i) B. Sun Microsystems​
ii) D. String​
iii) C. &&​
iv) B. 2 bytes​
v) C. integer​
vi) C. x = 5;

Section B

(Answers will vary slightly. Here's a guideline)

Q7.​
a) OOP is a programming style that revolves around objects and classes.​
b) Inheritance, Encapsulation, Abstraction, Polymorphism​
c) Object: runtime entity; Class: blueprint; Method: function inside class

Q8.​
a) A literal is a constant value written directly, like 5, 'A', "Hello"​
b)

class Info {
public static void main(String[] args) {
String name = "Riya";
int age = 14;
System.out.println("Name: " + name);
System.out.println("Age: " + age);
}
}

c) x += 2; adds 2 to x

Q9.​
a) byte, short, int, long, float, double, char, boolean with examples​
b)

double d = 5.6;
int x = (int) d;

c) float pi = 3.14f;

Q10.​
a) = is assignment; == is comparison​
b)

int a = 10, b = 15;


int max = (a > b) ? a : b;
System.out.println("Max: " + max);

c) Used in conditions. boolean isPassed = true;

Q11.​
a) ++a increases before use; a++ after use​
b) *, +, ==, && (correct order)​
c) 2 + 6 - 1 = 7

Q12.​
a) Java bytecode runs on any system with JVM​
b)

int a = 10, b = 2;
System.out.println(a + b);
System.out.println(a - b);
System.out.println(a * b);
System.out.println(a / b);
System.out.println(a % b);

c) JVM interprets bytecode and enables platform independence

You might also like