This document contains multiple choice questions about Java programming concepts like exceptions, object-oriented programming, inheritance, and arrays. It tests knowledge of basic Java syntax and semantics. The questions cover a wide range of fundamental Java topics including variables, methods, packages, exceptions, inheritance, polymorphism, and arrays.
In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs—they are not technically incorrect and do not currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future.
A presentation on core java. in this ppt there are all the basic informations on the core java suvh as-
Features of Java
Java Program Translation
Java Virtual Machine
Java system overview
Java Program-Development phase
Advantage of java
Disadvantage of java
Project
In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs—they are not technically incorrect and do not currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future.
A presentation on core java. in this ppt there are all the basic informations on the core java suvh as-
Features of Java
Java Program Translation
Java Virtual Machine
Java system overview
Java Program-Development phase
Advantage of java
Disadvantage of java
Project
Goals1)Be able to work with individual bits in java.2).docxjosephineboon366
Goals
1)
Be able to work with individual bits in java
.
2)
Understand the serializable interface.
3)
Understand the comparable interface.
4)
Answer questions about a general-purpose class to be developed.
5)
Understand the use of a driver program for ‘glass box’ debugging.
6)
Develop a program that can grade true/false tests.
Synthesis Questions
1.
Why is it a good idea to test a general class with a driver program before trying to use it?
2.
What is the difference between black box and glass box debugging?
3.
In pseudo-code, describe
CreateTest.java.
4.
In pseudo code, describe the driver program that is provided below.
5.
If x = 37, y=23, z=-110, r=-32 answer the following questions. Assume that we are working with bytes. To answer these questions, you will need to convert from decimal to binary. Remember that
System.out.println
DOES NOT print binary values. You will need to convert your results to decimal. Of course you can verify your results by computer. Remember that there will be questions like this on the quiz, so try them yourself first.
a.
System.out.println
(
x&y
);
b.
System.out.println
(
x^y
);
c.
System.out.println
(~
x|y
);
d.
System.out.println
(~x>>2);
e.
System.out.println
((byte)(z<<(~r>>4)));
f.
System.out.println
((byte)(x + (x<<1) + (x<<2) + (x<<3)));
g.
System.out.println
(y>>>3);
h.
System.out.println
(
x&y|z^r
);
i.
System.out.println
(~x + x);
j.
System.out.println
(x|(3<<4));
6.
In
about
a sentence, give a reasonable example of when the following operators would be useful when working with strings of bits.
a.
or operation (|):
b.
and operation (&):
c.
exclusive or operation (^):
d.
left shift operation: (<<):
7.
Suppose we need to create a multiple-choice exam, where each question has four possible choices. Briefly describe (in a few sentences) how we could create a new class that uses inheritance that would allow this. Giving class API and a brief description of the needed methods would also suffice.
8.
Suppose we needed to modify the
BitMap
class to handle a bit stream of up to
16384
bits. Briefly describe the changes necessary to handle this refinement. Can you think of a way that the maximum number of bits to be handled is completely flexible?
Description
1)
The first step is to develop a general-purpose class that will be able to perform operations on strings of bits. The class API follows:
public class
BitMap
implements Comparable,
Serializable
{ public static final int BITSIZE = 64;
private
long bitString;
public BitMap
() // Three constructors.
public
BitMap
(String s)
throws
IndexOutOfBoundsException,ArithmeticException
public
BitMap
(
boolean
[] bits)
throws
IndexOutOfBoundsException
private
long
bitMask
(
int
b) // Other class methods.
public void
setBit
(
int
b)
public void
clearBit
(
int
b)
public
boolean
checkBit
(
int
b)
public
int
countTrue
()
public void
clearAll()
public void
setAll()
.
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxmaxinesmith73660
Consider this code using the ArrayBag of Section 5.2 and the Location class from Chapter 2. What is the output?
Location i = new Location(0, 3);
Location j = new Location(0, 3);
b.add(i);
b.add(j);
System.out.println(b.countOccurrences(i));
A. 0
B. 1
C. 2
D. 3
Suppose that b and c are Integer objects. A typical use of the clone method looks like this:
b = (Integer) c.clone( );
Write a short clear explanation of why the (Integer) type cast is required in this typical example.
A. obj = s;
B. s = obj;
C. s = (String) obj;
D. Two or more answers are correct.
Suppose that obj is an Object variable and s is a String variable. Which of the following statements
is a correctly-compiling widening conversion? Don't worry about possible run-time exceptions
A. obj = s;
B. s = obj;
C. s = (String) obj;
D. Two or more answers are correct.
Suppose that x and y are reference variables and a program activates x.equals(y). What occurs if x is the null reference?
A. A NullPointerException occurs
B. It always returns true.
C. It always returns false.
D. It returns true if y is also a null reference; otherwise it returns false.
Consider the implementation of the Stack using a partially-filled array.
What goes wrong if we try to store the top of the Stack at location [0] and the bottom of the Stack at the last used position of the array?
A. Both peek and pop would require linear time.
B. Both push and pop would require linear time.
C. The Stack could not be used to check balanced parentheses.
D. The Stack could not be used to evaluate postfix expressions.
Write some lines of code that declares an Integer object, using the Integer wrapper class.
Assign the value 42 to this object, then copy this value from the Integer object to an ordinary int variable.
Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?
A. 1
B. 2
C. 3
D. 4
E. 5 or more
Consider the usual algorithm to convert an infix expression to a postfix expression.
Suppose that you have read 10 input characters during a conversion and that the
stack now contains the symbols as shown below. Suppose that you read and process
the 11th symbol of the input. What symbol is at the top of the stack in the case where
the 11th symbol is each of the choices shown?
Which of the following stack operations could result in stack underflow?
Answer
A. is_empty
B. pop
C. push
D. Two or more of the above answers
What is the value of the postfix expression 6 3 2 4 + - *:
Answer
A. Something between -15 and -100
B. Something between -5 and -15
C. Something between 5 and -5
D. Something between 5 and 15
E. Something between 15 and 100
1. An array o.
Developer Tools covered:
-> deployment, on smartphone
-> debugging, via system messages
-> the best practices
Namely, popular libraries, naming conventions, and news to keep up to date.
The strength of Android is its community, follow it, to adopt its best practices.
Cmis 102 Effective Communication / snaptutorial.comHarrisGeorg12
CMIS 102 Homework 1 Solution
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
Online aptitude test management system project report.pdfKamal Acharya
The purpose of on-line aptitude test system is to take online test in an efficient manner and no time wasting for checking the paper. The main objective of on-line aptitude test system is to efficiently evaluate the candidate thoroughly through a fully automated system that not only saves lot of time but also gives fast results. For students they give papers according to their convenience and time and there is no need of using extra thing like paper, pen etc. This can be used in educational institutions as well as in corporate world. Can be used anywhere any time as it is a web based application (user Location doesn’t matter). No restriction that examiner has to be present when the candidate takes the test.
Every time when lecturers/professors need to conduct examinations they have to sit down think about the questions and then create a whole new set of questions for each and every exam. In some cases the professor may want to give an open book online exam that is the student can take the exam any time anywhere, but the student might have to answer the questions in a limited time period. The professor may want to change the sequence of questions for every student. The problem that a student has is whenever a date for the exam is declared the student has to take it and there is no way he can take it at some other time. This project will create an interface for the examiner to create and store questions in a repository. It will also create an interface for the student to take examinations at his convenience and the questions and/or exams may be timed. Thereby creating an application which can be used by examiners and examinee’s simultaneously.
Examination System is very useful for Teachers/Professors. As in the teaching profession, you are responsible for writing question papers. In the conventional method, you write the question paper on paper, keep question papers separate from answers and all this information you have to keep in a locker to avoid unauthorized access. Using the Examination System you can create a question paper and everything will be written to a single exam file in encrypted format. You can set the General and Administrator password to avoid unauthorized access to your question paper. Every time you start the examination, the program shuffles all the questions and selects them randomly from the database, which reduces the chances of memorizing the questions.
6th International Conference on Machine Learning & Applications (CMLA 2024)ClaraZara1
6th International Conference on Machine Learning & Applications (CMLA 2024) will provide an excellent international forum for sharing knowledge and results in theory, methodology and applications of on Machine Learning & Applications.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
1. Both the methods sleep and join throws Interrupted Exception.
Select an answer
*A. TRUE
B. FALSE
This is a legal int x[]={2,3,7,9};
Select an answer
*A. TRUE
B. FALSE
Can you automatically convert a long to an int if the long value is small enough
to fit into an int?
Select an answer
A. Yes
*B. No
Collection will not represent a single unit of objects.
Select an answer
A. TRUE
*B. FALSE
By default, all program import the java.lang package.
Select an answer
*A. TRUE
B. FALSE
Is it legal to access a static method using an instance of an class?
Select an answer
A. Yes
*B. No
A method can have more than one access modifier?
Select an answer
*A. TRUE
B. FALSE
A source stream initiates the flow of data, also called an input stream.
Select an answer
*A. TRUE
B. FALSE
ou can pass an object reference as an argument to a method call.
Select an answer
*A. TRUE
B. FALSE
When you pass a variable an argument to a method is called.
Select an answer
*A. TRUE
B. FALSE
When a Java program tries to divide by zero; the runtime will create and throw
an object of Arithmetic Exception.
2. Select an answer
*A. TRUE
B. FALSE
An object means, anything that can D25be seen or touched; material thing.
Select an answer
*A. TRUE
B. FALSE
Suppose that Marketing is a subclass of Department. What is casting used for in
the code? public organize (Department sales) { Marketing marketing1 =
(Marketing) sales ; }
(Please select ALL that apply)
Select an answer
A. To cast sales to a Marketing reference
B. To convert a Department object into a Marketing object
C. To make the code clearer
*D. To perform a narrowing conversion
Which constructs can you make private?
(Please select ALL that apply)
Select an answer
A. Local variables
*B. Member variables
*C. Methods
*D. Top-level classes
A byte can be of what size?
Select an answer
*A. -128 to 127
B. (-2 power 8)-1 to 2 power 8
C. -255 to 256
D. Depends on the particular implementation of the Java Virtual machine
What is a constructor?
Select an answer
A. A constructor is a special kind of method that determines how a
class is initialized when created
B. A constructor is a special kind of class that determines how an
object is initialized when created
*C. A constructor is a special kind of method that determines how an
object is initialized when created
D. A constructor is a special kind of method that determines how a
message is
A ref is a:
Select an answer
*A. Method of passing the values of parameters
B. Pointer to an object
C. Method of compiling the PL/SQL
D. A wrapper for encrypting the source
E. None of the options are correct
Identify the best examples of an inheritance hierarchy.
(Please select ALL that apply)
3. Select an answer
A. Animal extends Dog extends Cat
*B. Cappuccino extends Coffee extends Beverage
C. Director extends Manager extends Employee
D. Vehicle extends Car
<p>What happens when you put this expression in your code? </p>int x=0; int y =
4%x;
Select an answer
*A. Compile time error
B. Compiles and runs
C. Runtime exception
Can we create one or more package declaration per source file?
Select an answer
A. Yes, specify multiple package declaration at starting of the program
*B. No you can have only one package declaration per file
C. Yes, you can use scope braces to show which package definition holds
good for respected blocks
D. None of the options are correct
You have a method that throws a checked exception. What is required to ensure
that the code correctly compiles and any potential exceptions are handled by all
callers to this method?
(Please select ALL that apply)
Select an answer
*A. The called method must be declared with a throws clause
*B. The calling method must either enclose the method call in a
try...catch block or declare the relevant exception to be thrown
C. The calling method must include a catch block for each specific type
of exception thrown by the called method
D. The calling method must override a method of a superclass
Suppose you have an abstract Vehicle class. The Ford class extends the Car
class, which extends the Vehicle class, and overrides its getSpec method. You
assign a Ford reference to a variable, vehicle, of type Vehicle. Which getSpec
method is called through vehicle? Vehicle a = new Ford(); a.getSpec();
Select an answer
A. The getSpec method of the Car object
*B. The getSpec method of the Ford object
C. The getSpec method of the Vehicle object
Suppose you needed to pass a variable number of integer arguments to the
newMethod method and have to make use of the varargs feature. Which statement is
syntactically correct?
Select an answer
A. static void newMethod ( intnumbr[] )
*B. static void newMethod ( int ... numbr )
C. static void newMethod ( int --- numbr )
D. static void newMethod ( boolean ... numbr )
The three basic read methods are:
(Please select ALL that apply)
Select an answer
A. int read([]char)
4. B. int read()
*C. int read(char[] cbuf)
*D. int read(char[] cbuf, int offset, int length
What is the work of java Runtime environment?
(Please select ALL that apply)
Select an answer
A. Creates code
B. Loads code
C. Verifies code
D. Executes code
*E. None of the options are correct
What will be the output of the program?
public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
Select an answer
*A. Finally
B. Compilation fails.
C. The code runs with no output.
D. An exception is thrown at runtime.
Which three form part of correct array declarations?
(Please select ALL that apply)
Select an answer
*A. public int a [ ]
*B. static int [ ] a
*C. public [ ] int a
D. private int a [3]
E. private int [3] a [ ]
F. public final int [ ] a