Final Exam (page 1 of 3) PDF

Title Final Exam (page 1 of 3)
Author Anas Saker
Course Programming 1
Institution University of the People
Pages 8
File Size 206.5 KB
File Type PDF
Total Downloads 92
Total Views 148

Summary

Final Exam Part 1...


Description

Anas Haj Sakor

Home  My courses  CS 1102 - AY2021-T4  Final Exam (Days 1 - 4)  Final Exam

Question 1

Not yet answered

Marked out of 1.00

What is the output of the following Java program?

import java.util.*; class ArrayGames { public static void main(String[] args) { int[] a = {1,2,3,4,5}; System.out.println(a[1]); } } Select one: a. 1 b. 2 c. 3 d. 4 e. 5 Clear my choice



Question 2

Not yet answered

Marked out of 1.00

Consider the following Java program. 1 public class HelloWorld { 2

// My first program!

3

public static void main(String[] args) {

4

System.out.println("Hello, World!");

5

}

6 } What starts on line 4? Select one: a. a statement b. a package c. a method definition d. a comment e. a class definition Clear my choice



Question 3

Not yet answered

Marked out of 1.00

What is output by the following Java program?

class Compute { static int compute() { return 41; } static int compute(int i) { return i+1; } public static void main(String[] args) { System.out.println(compute(compute())); } } Select one: a. 0 b. 1 c. 2 d. 41 e. 42 Clear my choice

Question 4

Not yet answered

Marked out of 1.00

Each of the individual tasks that a CPU is working on is called: Select one: a. a component b. an address c. a message d. an object e. a thread Clear my choice



Question 5

Not yet answered

Marked out of 1.00

Consider the following Java program. 1 public class HelloWorld { 2

// My first program!

3

public static void main(String[] args) {

4

System.out.println("Hello, World!");

5

}

6 } What starts on line 3? Select one: a. a statement b. a package c. a method definition d. a comment e. a class definition Clear my choice



Question 6

Not yet answered

Marked out of 1.00

Consider the following Java method.

public static void main(String[] args) { System.out.println("Hello, Final!"); } Which term best describes "String[] args"? Select one: a. actual parameter or argument b. formal parameter c. modifier d. return type e. superclass Clear my choice

Question 7

Not yet answered

Marked out of 1.00

What does a Java compiler do? Select one: a. Runs Java programs. b. Translates byte code in ".java" files into machine language. c. Translates source code in ".class" files into machine language. d. Translates source code in ".java" files into Java byte code in ".class" files. e. Translates source code in ".txt" files into machine language. Clear my choice



Question 8

Not yet answered

Marked out of 1.00

Which one of the following is used in Java programming to handle asynchronous events? Select one: a. constructors b. event handlers c. overloading d. pragmatics e. protocols Clear my choice



Question 9

Not yet answered

Marked out of 1.00

Consider the following Java program.Which one of the following best describes "pepper"?

public class Food { static int count; private String flavor = "sweet"; Food() { count++; } void setFlavor(String s) { flavor = s; } String getFlavor() { return flavor; } static public void main(String[] args) { Food pepper = new Food(); System.out.println(pepper.getFlavor()); } } Select one: a. a constructor b. a local object variable c. an instance variable d. a method e. a class variable Clear my choice



Question 10

Not yet answered

Marked out of 1.00

Consider the following Java program.Which one of the following is a package?

import java.awt.event.*; import javax.swing.*; public class MouseWhisperer extends JFrame implements MouseListener { MouseWhisperer() { super("COME CLOSER"); setSize(300,100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); addMouseListener(this); setVisible(true); } public void mouseClicked(MouseEvent e) { setTitle("OUCH"); } public void mousePressed(MouseEvent e) { setTitle("LET GO"); } public void mouseReleased(MouseEvent e) { setTitle("WHEW"); } public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU"); } public void mouseExited(MouseEvent e) { setTitle("COME CLOSER"); } public static void main(String[] args) { new MouseWhisperer(); } } Select one: a. java.awt.event b. JFrame c. MouseEvent d. MouseListener e. super Clear my choice

◄ Review Quiz Jump to...

...


Similar Free PDFs