Week 7 To 9

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

SUBJECT (PROGRAMMING) (Quarter/1Week 7 - 9)

Prepared by:(GLENN L. TABUCANON)

WEEK 7
Activity 1

ANSWER SHEET

Java Programming
Name: Semense, Maria Nilca P. Activity Title: ______________________________
Grade Level and Section: Grade 12 San Fernando

Activity

Answer the following questions.

1. What is a correct syntax to output "Hello World" in Java?


Answer: the main method public static void main(String args[]){ Now Type the System. Out.
Println(“Hello World”); which will print Hello World in Java.
2. Java is short for "JavaScript". True or False
Answer: False
3. How do you insert COMMENTS in Java code?
Answer: The single line comment is //. Everything from the // to the end of the line is a comment. To
mark an entire region as a comment, use /* to start the comment and */ to end the comment. * This is a
block comment.
4. What data type is used to create a variable that should store text?
Answer: String (str or text). It is a sequence of characters and the most commonly used data type to
store text.
5. How do you create a variable with the numeric value 5?
Answer: They are declared simply by writing a whole number. For example, the statement x = 5 will
integer number 5 in the variable x.

6. How do you create a variable with the floating number 2.8?


Answer: float(2.8)
7. Which method can be used to find the length of a string?
Answer: The length() method is a method that is applicable for string objects. length() method returns
the number of characters present in the string. The length() method is suitable for string objects but not
for arrays. The length() method can also be used for StringBuilder and StringBuffer classes.
8. What operator is used to add together two values?
Answer: +Addition
9. Is it true that the value of a string variable can be surrounded by single quotes.
Answer: No, String values are surrounded by double quotes.
10. What operator can be used to compare two values?

Page 1 of 6
SUBJECT (PROGRAMMING) (Quarter/1Week 7 - 9)
Prepared by:(GLENN L. TABUCANON)

Answer: Both “is” and “==” are used for object comparison in Python. The operator “==” compares values
of two objects, while “is” checks if two objects are same (In other words two references to same object).

11. How do you create a method in Java?


Answer:
12. How do you call a method in Java?
Answer: To call a method in Java, write the method's name followed by two parentheses () and a
semicolon; The process of method calling is simple. When a program invokes a method, the program
control gets transferred to the called method.
13. What operator is used to multiply numbers?
Answer: arithmetic operator is used to multiply numbers.
14. What are the different Primitive data types?
Answer: The eight primitive data types are: byte, short, int, long, float, double, char, and boolean. Upper
and lower case characters are important in these names.
15. What data type that can store data type can store whole numbers from -9223372036854775808 to
9223372036854775807?
Answer: quad integer data type

Page 2 of 6
SUBJECT (PROGRAMMING) (Quarter/1Week 7 - 9)
Prepared by:(GLENN L. TABUCANON)

WEEK 8
Activity 1

ANSWER SHEET

Java Programming
Name: ____________________________________ Activity Title: ______________________________
Grade Level and Section: ____________________

1. What is JVM? Why is Java called the ‘Platform Independent Programming Language’?
Answer: Java is class based and object oriented programming language. This bytecode is sent to Java
virtual machine (JVM) which resides in the RAM of any operating system. JVM recognizes the platform
it is on and converts the bytecodes into native machine code. Hence java is called platform
independent language.
2. What is the Difference between JDK and JRE?
Answer: JDK(Java Development Kit) is used to develop Java applications. JDK also contains
numerous development tools like compilers, debuggers, etc. JRE(Java Runtime Environment) is the
implementation of JVM(Java Virtual Machine) and it is specially designed to execute Java programs.
3. What does the ‘static’ keyword mean?
Answer: In the Java programming language, the keyword static indicates that the particular member
belongs to a type itself, rather than to an instance of that type. This means that only one instance of
that static member is created which is shared across all instances of the class.
4. In order to run Java program, we need to install __________application program.
Answer: To run a java program, we need to install the “Java Development Kit” (JDK) application
program.
5. Previously Java was known as ________.
6. Answer: Oak is a discontinued programming language created by James Gosling in 1989, initially for
Sun Microsystems’ set-top box project. The language later evolved to become Java. The name Oak
was used by Gosling after an oak tree that stood outside his office.
7. Java is a _____________language.
Answer: Java is a popular programming language
8. Java is developed by__________.
Answer: Java was originally developed by James Gosling at Sun
9. What do you mean by JRE?
Answer: JRE (Java Runtime Environment) is an installation package that provides an environment to
only run(not develop) the java program(or application)onto your machine.
10. Java is developed by___________.
Answer: Java was originally developed by James Gosling at Sun

Page 3 of 6
SUBJECT (PROGRAMMING) (Quarter/1Week 7 - 9)
Prepared by:(GLENN L. TABUCANON)

11. What is the following operation(s) is/are required to convert the java source code into output form.
Answer: The java command compiles Java source code into Java bytecodes, stores the resulting
bytecodes in a class file with a name of the form “class name.
12. Is java 100% object oriented language?
Answer: Java is not fully object oriented because it supports primitive data type like it,byte,long etc.
Which are not objects. Because in JAVA we use data types like int, float, double etc. which are not
object oriented, and of course is what opposite of OOP is. That is why JAVA is not 100% objected
oriented.
13. Java _________the program first and then __________it. Answer: A and C
a.) compile
b.) interpret
c.) assemble
d.) debug
14. What is the extension of the Java program?
Answer:
15. They are used to perform operations on variables and values.
Answer: Operators are used to perform operations on variables and values.

Page 4 of 6
SUBJECT (PROGRAMMING) (Quarter/1Week 7 - 9)
Prepared by:(GLENN L. TABUCANON)

WEEK 9
Activity 1

ANSWER SHEET

Java Programming
Name: ____________________________________ Activity Title: ______________________________
Grade Level and Section: ____________________

Write a program form the given problem, but before you write the program show solution by creating a
Flowchart and a Pseudocode.

1. Write a program and showing the flowchart and pseudocode in Java that will ask the user to input three
numbers and then the program will find the total sum of tree numbers given by the user.
Sample output:
======== ADDITION OF THREE NUMBER =========
Enter First Number : 1
Enter Second Number: 2
Enter Third Number: 3
The sum of 1, 2, and 3 is: 6

Solution:

// addition_of_three_numbers.java
// Date: Sept 22, 2021
// Written By: Name of Student
import java. util.Scanner;
class addition_of_three_numbers {
public static void main(String args(]) {
Scanner scan = new Scanner(System.in);
System.out.println();
System.out.println(“======== ADDITION OF THREE NUMBERS =========”);
System.out.println();
System.out.print("Enter First Number : ");
int a = scan.nextlnt();
System.out.print("Enter Second Number :”);
int b = scan.nextlnt();
Page 5 of 6
SUBJECT (PROGRAMMING) (Quarter/1Week 7 - 9)
Prepared by:(GLENN L. TABUCANON)

System.out.print("Enter Third Number :”);


int c = scan.nextlnt();
int sum = (a+b+c);
System.out.println();
System.out.print("The sum of "+a + “, " +b+ “ and "+ c+"is"+ sum+ “.”);
System.out.println(“\n\n”);
System.out.println(“-----------END of Program------------“);
System.out.println();
}
} //END OF PROGRAM

2. Write a program and showing the flowchart and Pseudocode in Java that will compute the area of the
circle. Use the formula: Area = ? r2 where Pi (?) is approximately to 3.1416
Sample output:
*************** AREA OF THE CIRCLE SOLVER **************
Enter the radius of the circle: 10
The given radius is 10 the area of the circle is 3.1416

3. Write a program and showing the flowchart and Pseudocode in Java that takes the user for a distance
(in meters) and the time was taken (as three numbers: hours, minutes, seconds), and display the
speed, in meters per second, kilometers per hour and miles per hour (hint: 1 mile = 1609 meters).

Test Data
Input distance in meters: 2500
Input hour: 5
Input minutes: 56
Input seconds: 23
Expected Output :
Your speed in meters/second is 0.11691531
Your speed in km/h is 0.42089513
Your speed in miles/h is 0.26158804

Page 6 of 6

You might also like