Midterm - CIT 111 - Intro To Java

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Jeffreyjseaman
J
Jeffreyjseaman
Community Contributor
Quizzes Created: 1 | Total Attempts: 108
Questions: 50 | Attempts: 108

SettingsSettingsSettings
Midterm - CIT 111 - Intro To Java - Quiz


Name:_________________ Date: __________________


Questions and Answers
  • 1. 

    What is missing from the try and catch method? try {      UIManager.setLookAndFeel("Java is Awesome.."); }catch(Exception exc)

  • 2. 

    Declare an Integer, defined name and values are below.Integer Name is mynumbermynumber value is 22

  • 3. 

    Write out how you would import the class "java.util.Scanner"?

  • 4. 

    Declare a String and assign a value to the string as you would in Java programming code.1. String name is: city2. City Name is: Pittsburgh

  • 5. 

    Below is a simple Frame program we worked on in class. See what is missing and write it below? import javax.swing.*; public class SimpleFrame extends JFrame{ public SimpleFrame(){super("Frame Title");setSize(300,522);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setVisible(true); } private static void setLookAndFeel(){try {UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");   } catch(Exception exc){//ignore error }} public static void main(String[]arguments){setLookAndFeel();SimpleFrame sf = new SimpleFrame();//sf.setVisible(false);} }

  • 6. 

    Write out the main class of a java class program

  • 7. 

    In the following module you have a main class, and a method called void. Write out how you would call the Void method?//Main Class public static void main(String[] args) {// TODO Auto-generated method stub  } //Method public static void Info(){        //Do something...        }

  • 8. 

    What would be my output with the following source code?String lastName = "Walker";String firstName = "Neil";String Name = lastName + " " + firstName;System.out.println(Name);

  • 9. 

    Is a Container object in GUI programming a primitive variable that contains...    

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A Container object in GUI programming is not a primitive variable, but rather a higher-level object that can contain and organize other GUI components such as buttons, labels, and text fields. It provides a way to group and layout these components within a graphical user interface. Therefore, the given answer "True" is correct as it correctly states that a Container object is not a primitive variable.

    Rate this question:

  • 10. 

    The size of a frame on the screen is measured in pixels

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The size of a frame on the screen is measured in pixels because pixels are the smallest units of measurement on a digital display. Each pixel represents a tiny dot on the screen, and the overall size of a frame is determined by the number of pixels it occupies horizontally and vertically. This measurement is important for determining the resolution and clarity of an image or video displayed on the screen.

    Rate this question:

  • 11. 

    What is the difference between private and public functions

    • A.

      Public can be used by anyone, private can only be used by other code in the class you are writing

    • B.

      Public are free

    • C.

      Public can't be used

    • D.

      Public is only for .NET

    Correct Answer
    A. Public can be used by anyone, private can only be used by other code in the class you are writing
    Explanation
    Public and private functions are two different access modifiers in programming. The correct answer explains that public functions can be accessed by anyone, while private functions can only be accessed by other code within the same class. This means that public functions are accessible from outside the class, allowing other parts of the program to use them. On the other hand, private functions are restricted to the class they are defined in, ensuring that they can only be used internally within that class. This encapsulation helps in maintaining code organization and security.

    Rate this question:

  • 12. 

    A method can be defined within the body of another method.  This is known as nesting methods?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A method can indeed be defined within the body of another method, which is known as nesting methods. This allows for a more organized and modular approach to programming, as the nested method can be used only within the scope of the outer method. This can help in reducing code complexity and improving code readability.

    Rate this question:

  • 13. 

    To use the method Math.sqrt(x) you must import the package java.lang.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    To use the method Math.sqrt(x), you need to import the package java.lang. This is because the Math class is part of the java.lang package, which contains fundamental classes that are automatically imported into every Java program. By importing java.lang, you have access to the Math class and its sqrt() method, which calculates the square root of a given number. Therefore, the correct answer is True.

    Rate this question:

  • 14. 

    Void methods are always stand-alone statements

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Void methods are always stand-alone statements because they do not return any value. They are used to perform a specific action or task without needing to return a result. Since they do not have a return type, they cannot be used as part of an expression or assigned to a variable. Therefore, void methods are typically written as individual statements that can be called or executed independently.

    Rate this question:

  • 15. 

    It is possible to create several methods with the same name in a single class

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    In object-oriented programming, it is possible to create several methods with the same name in a single class. This is known as method overloading. Method overloading allows developers to define multiple methods with the same name but with different parameters or different types of parameters. When the method is called, the appropriate version of the method is executed based on the arguments passed to it. This feature allows for code reusability and flexibility in designing classes.

    Rate this question:

  • 16. 

    Is the name of the Swing class used for frames called SwingFrame

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The name of the Swing class used for frames is not called SwingFrame. Swing is a set of GUI components in Java, and the class used for frames is called JFrame. So, the correct answer is False.

    Rate this question:

  • 17. 

    When you create a JFame object it is not automatically displayed.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    When you create a JFame object in Java, it is not automatically displayed because the display of the JFrame object is controlled by the programmer. The programmer needs to explicitly call the setVisible(true) method on the JFrame object to make it visible on the screen. By default, the visibility of the JFrame object is set to false, so it needs to be manually set to true in order to be displayed.

    Rate this question:

  • 18. 

    A requirements document may specify that a new program be developed or they may specify updates to an existing program.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A requirements document serves as a guideline for developing or updating a program. It outlines the necessary features, functionalities, and specifications that the program should have. Therefore, it is true that a requirements document may specify the development of a new program or updates to an existing program.

    Rate this question:

  • 19. 

    You may declare an unlimited number of variables in a statement as long as the variables are the same data type

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    In programming, you can declare multiple variables in a single statement as long as they are of the same data type. This allows for more concise and efficient code. However, it is important to note that each variable must be separated by a comma and have the same data type.

    Rate this question:

  • 20. 

    As you develop a Java program you can use Eclipse to watch the stock options online

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Eclipse is an integrated development environment (IDE) that supports Java programming. It provides various features and tools to assist in the development process. One of these features is the ability to connect to the internet and access online resources. Therefore, it is possible to use Eclipse to watch stock options online while developing a Java program. Hence, the answer is true.

    Rate this question:

  • 21. 

    A syntax error occurs when there's a syntax error in a Java Statement

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A syntax error occurs when there is a mistake or error in the syntax of a Java statement. This means that the statement does not follow the proper rules and structure of the Java programming language. Syntax errors are common mistakes made by programmers and can prevent the code from compiling or executing correctly.

    Rate this question:

  • 22. 

    A console application uses a graphical user interface

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A console application typically does not use a graphical user interface (GUI), as it is designed to interact with the user through text-based input and output. Instead, console applications are run in a command-line interface, where the user enters commands and receives text-based responses. Therefore, the statement that a console application uses a graphical user interface is false.

    Rate this question:

  • 23. 

    A class is an object or a set of objects that share a common structure but not a common behavior

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    This statement is true because a class in object-oriented programming is a blueprint for creating objects. It defines the structure and properties that the objects of that class will have, but it does not define the specific behavior or actions that those objects will perform. The behavior of objects is defined by methods or functions within the class. Therefore, a class can be seen as a common structure shared by objects, but the specific behavior can vary between objects.

    Rate this question:

  • 24. 

    What is the size of a Char in Java

    • A.

      4 Bit

    • B.

      16 Bit

    • C.

      8 Bit

    • D.

      7 Bit

    Correct Answer
    A. 4 Bit
    Explanation
    In Java, the size of a Char is 16 bits. This is because a Char data type represents a single character and uses the Unicode character set, which requires 16 bits to represent a wide range of characters from different languages and symbols. Therefore, the correct answer is 16 Bit.

    Rate this question:

  • 25. 

    A Class is

    • A.

      Object

    • B.

      Variable

    • C.

      Executable

    • D.

      Program

    Correct Answer
    A. Object
    Explanation
    A class is an object in object-oriented programming. It serves as a blueprint or template for creating objects, which are instances of the class. Objects can have properties (variables) and behaviors (executable code) defined by the class. Therefore, a class is not a variable, executable, or program itself, but rather a construct that represents an object.

    Rate this question:

  • 26. 

    What is a program? Choose between the examples below

    • A.

      Wakeup, Brush my teeth, Floss my teeth, shave, and trim my eye brows

    • B.

      Drive a car, Wake up in the morning, yawn at work, Take a nap at night

    • C.

      Jump out of your chair at work, Go fishing on Lake Erie

    • D.

      Jump and lay down

    Correct Answer
    A. Wakeup, Brush my teeth, Floss my teeth, shave, and trim my eye brows
  • 27. 

    What was the name of the team at Sun Systems that developed Java

    • A.

      Blue man Group

    • B.

      Green Team

    • C.

      Gurus

    • D.

      Microsoft + Apple

    Correct Answer
    A. Blue man Group
    Explanation
    The team at Sun Systems that developed Java was called the Blue man Group.

    Rate this question:

  • 28. 

    A Data item is blank when it cannot be changed while a program is running

    • A.

      Input

    • B.

      Scanner

    • C.

      Constant

    • D.

      Boolean

    Correct Answer
    A. Input
    Explanation
    The correct answer is "input" because an input data item refers to a value that is provided by the user or an external source and can be changed while the program is running. In contrast, a constant is a data item whose value remains the same throughout the program's execution, and a boolean is a data type that represents a value of either true or false. A scanner is a class in Java that allows for user input to be read from the console.

    Rate this question:

  • 29. 

    Is a named memory location that you can use to store a value

    • A.

      Variable

    • B.

      Constant

    • C.

      Integer

    • D.

      Reference

    Correct Answer
    A. Variable
    Explanation
    A variable is a named memory location that can be used to store a value. It allows programmers to assign and manipulate data within a program. Unlike constants, variables can be changed and updated throughout the execution of a program. Variables can hold different types of data, such as integers, strings, or objects. They provide flexibility and adaptability in programming, allowing for dynamic and interactive applications.

    Rate this question:

  • 30. 

    Is a built-in class that provides you with the means for storing and manipulating character strings

    • A.

      Boolean

    • B.

      String

    • C.

      Remainder

    • D.

      Integer Division

    Correct Answer
    A. Boolean
  • 31. 

    A Dialog box asks a question and provides a text field in which the user can enter a response.

    • A.

      Output

    • B.

      Input

    • C.

      Console

    • D.

      String

    Correct Answer
    B. Input
    Explanation
    A dialog box is a graphical user interface element that prompts the user with a question or message and provides a text field for the user to enter a response. The input option is the correct answer because it accurately describes the text field where the user can enter their response in the dialog box. The other options, output, console, and string, do not accurately describe the purpose or functionality of a dialog box.

    Rate this question:

  • 32. 

    The extension for a Java source file is

    • A.

      .txt

    • B.

      .jv

    • C.

      .java

    • D.

      .aspx

    Correct Answer
    C. .java
    Explanation
    The correct answer is .java because Java source files are typically saved with the .java extension. This allows the Java compiler to recognize and process the file as a Java source code file.

    Rate this question:

  • 33. 

    In Java, you use variables of type to store integers, or whole numbers

    • A.

      Int

    • B.

      Plus Sign

    • C.

      Single

    • D.

      Arithmetic

    Correct Answer
    A. Int
    Explanation
    In Java, the correct data type to store integers, or whole numbers, is "int". This data type is used to declare variables that can hold integer values.

    Rate this question:

  • 34. 

    What window does Eclipse use to get input from a console application

    • A.

      DOS

    • B.

      UNIX

    • C.

      Console Window

    • D.

      Excel

    Correct Answer
    C. Console Window
    Explanation
    Eclipse uses the "Console Window" to get input from a console application. This window allows users to interact with the console application by providing input and receiving output. It is the standard interface for input and output operations in Eclipse, specifically designed for console-based applications. The other options, DOS, UNIX, and Excel, are not relevant in this context as they do not pertain to Eclipse's console application input.

    Rate this question:

  • 35. 

    To create a java source file you use a

    • A.

      SQL Server

    • B.

      Text Editor

    • C.

      Google Chrome

    • D.

      Write on a Chalkboard

    Correct Answer
    B. Text Editor
    Explanation
    To create a Java source file, you need to use a text editor. A text editor is a software application that allows you to write and edit plain text. Java source code is written in plain text format, so a text editor is the appropriate tool for creating Java source files. SQL Server is a database management system, not a text editor. Google Chrome is a web browser, and writing on a chalkboard is not a digital method of creating a Java source file.

    Rate this question:

  • 36. 

    Java runs on which systems

    • A.

      Apple

    • B.

      Windows

    • C.

      Linux

    • D.

      All Above

    Correct Answer
    D. All Above
    Explanation
    Java is a programming language that can run on multiple systems, including Apple, Windows, and Linux. Therefore, the correct answer is "All Above" because Java is compatible with all of these operating systems.

    Rate this question:

  • 37. 

    What will be the value of “num” after the following statements? int num; num = (5+4); num = num / 9; num = 9;

    • A.

      9

    • B.

      Num

    • C.

      1

    • D.

      0

    Correct Answer
    A. 9
    Explanation
    The value of "num" will be 9 because the variable "num" is initially assigned the value of (5+4) which is 9. Then, the value of "num" is divided by 9, resulting in 1. However, the next statement assigns the value of 9 to "num", overriding the previous value and making "num" equal to 9 again.

    Rate this question:

  • 38. 

    With inheritance, a derived subclass object can directly access any

    • A.

      Protected Sub Class

    • B.

      Public Super Class

    • C.

      Private Subclass

    • D.

      Stingray Class

    Correct Answer
    B. Public Super Class
    Explanation
    Inheritance allows a derived subclass object to directly access any public member of its super class. This means that the derived subclass object can access any public method or variable defined in the public super class. Protected and private members are not directly accessible by the derived subclass object, but they can still be accessed through public methods defined in the super class. The Stingray Class is not mentioned in the question and is therefore not relevant to the explanation.

    Rate this question:

  • 39. 

    What does GUI stand for

    • A.

      Great Unicorn Investment

    • B.

      Graphical User Interface

    • C.

      Georgia Utah Iowa

    • D.

      Graphical User Intercase

    Correct Answer
    B. Graphical User Interface
    Explanation
    GUI stands for Graphical User Interface. It is a type of interface that allows users to interact with electronic devices through visual elements such as icons, buttons, and menus. This type of interface provides a more user-friendly and intuitive way of interacting with computers and software applications, as compared to text-based interfaces. GUIs are widely used in various devices and platforms, including computers, smartphones, and tablets, to enhance the user experience and make it easier for users to navigate and operate the system.

    Rate this question:

  • 40. 

    Which is not correct

    • A.

      An object is a variable, where its type is the class used to declare the variable

    • B.

      An objects exists in memory in run time

    • C.

      A class needs to be instantiated as a object before

    • D.

      Class and objects are just different names for the same thing

    Correct Answer
    D. Class and objects are just different names for the same thing
    Explanation
    This statement is not correct because a class and an object are not the same thing. A class is a blueprint or template for creating objects, while an object is an instance of a class. A class defines the properties and behaviors that an object will have, and multiple objects can be created from the same class. Therefore, a class and an object are distinct entities with different roles in object-oriented programming.

    Rate this question:

  • 41. 

    Choose the best definition of an object

    • A.

      Instance of a class

    • B.

      A Thing

    • C.

      NFL Superstar

    • D.

      Class Variable

    Correct Answer
    A. Instance of a class
    Explanation
    An object can be defined as an instance of a class. In object-oriented programming, a class is a blueprint for creating objects. An object is created based on this blueprint, and it contains the data and behavior defined by the class. Therefore, an object can be considered as an instance of a class. The other options, such as "A Thing," "NFL Superstar," and "Class Variable," do not accurately define an object in the context of programming.

    Rate this question:

  • 42. 

    Upon clicking the X (close) button on a window, it looks like you have "killed" the program, when in reality it keeps on running, but you see no frame.  This happened because you forgot to use the setDefaultCloseOperation( ) method so by default it used 

    • A.

      JFrame.HIDE_ON_CLOSE

    • B.

      JFRAME.EXIT_ON_CLOSE

    • C.

      JFrame.DO_NOTHING_CLOSE

    • D.

      JFrame.DISPOSE_ON_CLOSE

    Correct Answer
    A. JFrame.HIDE_ON_CLOSE
    Explanation
    When you click the X (close) button on a window, the program may appear to be "killed" because the window frame disappears. However, in reality, the program continues to run in the background. This happens because you forgot to use the setDefaultCloseOperation() method to specify the desired behavior when the window is closed. By default, the program uses JFrame.HIDE_ON_CLOSE, which hides the window but keeps the program running.

    Rate this question:

  • 43. 

    This is a data type that can hold 14 or 15 significant digits of accurarcy

    • A.

      Integer

    • B.

      Float

    • C.

      Double

    • D.

      String

    Correct Answer
    C. Double
    Explanation
    A double is a data type that can hold 14 or 15 significant digits of accuracy. It is used to represent decimal numbers with a high degree of precision. Unlike integer and float data types, which have limited decimal places, a double can store more precise values. Therefore, a double is the correct answer in this case.

    Rate this question:

  • 44. 

    What is the value that is returned in the following method? public static int getVolume() {   int v;    v = 23;   if (v < 50) {      return 50;   }   return v;}

    • A.

      50

    • B.

      12

    • C.

      100

    • D.

      233

    Correct Answer
    A. 50
    Explanation
    The value that is returned in the given method is 50. This is because the variable v is initially assigned the value of 23. However, the if statement checks if v is less than 50, which is true in this case. Therefore, the method returns the value 50.

    Rate this question:

  • 45. 

    How do you import all the classes in the AWT and Swing packages

    • A.

      Import awt.* import.javax.swing.*

    • B.

      Import awt/swing

    • C.

      Import awt and swing;

    • D.

      Do nothing

    Correct Answer
    A. Import awt.* import.javax.swing.*
    Explanation
    To import all the classes in the AWT and Swing packages, you need to use the statement "import awt.*" to import all the classes in the AWT package, and "import javax.swing.*" to import all the classes in the Swing package. This will allow you to access and use all the classes from these packages in your code.

    Rate this question:

  • 46. 

    Which of the following sets the frame to 300 pixels wide by 200 high

    • A.

      Frm.setVisible(300,200);

    • B.

      Frm.setSize( 300, 200 );

    • C.

      Frm.paint( 300, 200 );

    • D.

      Frm.paintanddry( 300, 200 );

    Correct Answer
    A. Frm.setVisible(300,200);
    Explanation
    The correct answer is Frm.setVisible(300,200);. This method sets the visibility of the frame and also sets its size to 300 pixels wide and 200 pixels high.

    Rate this question:

  • 47. 

    Choose the data type for value of true

    • A.

      Double

    • B.

      Int

    • C.

      String

    • D.

      Boolean

    Correct Answer
    D. Boolean
    Explanation
    The correct answer is Boolean because the value of true is represented by the Boolean data type. Boolean is a data type that can only have two possible values: true or false. In programming, Boolean variables are commonly used to store and manipulate logical values.

    Rate this question:

  • 48. 

    Following code will result in: class A { public static void main(String [] args) {A a = new B(); }} class B extends A {}

    • A.

      Compile error

    • B.

      Runtime Exception

    • C.

      No Errors

    • D.

      Output B

    Correct Answer
    C. No Errors
    Explanation
    The code will not result in any errors because class B extends class A, so it is a valid assignment to create an object of class B and assign it to a variable of type A. Therefore, the code will compile successfully and run without any errors.

    Rate this question:

  • 49. 

    A class can't be declared

    • A.

      Private

    • B.

      Default

    • C.

      Static

    • D.

      Protected

    Correct Answer
    A. Private
    Explanation
    In Java, a class cannot be declared as private because the private access modifier restricts the access to the members of a class only within the same class. However, a class can be declared with default, static, or protected access modifiers. The default access modifier allows access within the same package, the static access modifier is used to define a class-level variable or method that can be accessed without creating an instance of the class, and the protected access modifier allows access within the same package or subclasses in different packages.

    Rate this question:

  • 50. 

    This is a data type that can hold 14 or 15 significant digits of accurarcy

    • A.

      Integer

    • B.

      Float

    • C.

      Double

    • D.

      String

    Correct Answer
    C. Double
    Explanation
    A double is a data type that can hold 14 or 15 significant digits of accuracy. It is used to represent decimal numbers with a high level of precision. Unlike integers, floats, and strings, a double can handle larger and more precise numbers, making it suitable for calculations that require a high degree of accuracy.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jul 17, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 29, 2015
    Quiz Created by
    Jeffreyjseaman
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.