Package deal
programming in java questions and answers 2023/2024
programming in java questions and answers 2023/2024 the document contains over 450 questions and 100% accurate answers
[Show more]programming in java questions and answers 2023/2024 the document contains over 450 questions and 100% accurate answers
[Show more]36 JAVA QUESTIONS AND 100% ACCURATE ANSWERS 
1. If the following statement were used in a Java program, it would cause something to be written to the screen. What would it cause to be written to the screen? 
Sln("Java is not a drink."); 
2. Give a statement or statements that can be used in a Java...
Preview 2 out of 10 pages
Add to cart36 JAVA QUESTIONS AND 100% ACCURATE ANSWERS 
1. If the following statement were used in a Java program, it would cause something to be written to the screen. What would it cause to be written to the screen? 
Sln("Java is not a drink."); 
2. Give a statement or statements that can be used in a Java...
1. 	What output is produced by the following lines? 
String s = "Hello" + "Joe"; 
Sln(s); 
2. 	Write Java statements that will cause the following to be written to the screen: 
One two buckle your shoe. 
Three four shut the door. 
3.	 What is the difference between Sln and S ? 
4.	 What is the o...
Preview 2 out of 9 pages
Add to cart1. 	What output is produced by the following lines? 
String s = "Hello" + "Joe"; 
Sln(s); 
2. 	Write Java statements that will cause the following to be written to the screen: 
One two buckle your shoe. 
Three four shut the door. 
3.	 What is the difference between Sln and S ? 
4.	 What is the o...
Preview 3 out of 21 pages
Add to cartExam (elaborations) programming in java
Preview 4 out of 43 pages
Add to cartExam (elaborations) java
1. In the array declaration 
String[] word = new String[5]; 
what is 
a. the array name? 
b. the base type? 
c. the length of the array? 
d. the range of values an index accessing this array can have? 
e. one of the indexed variables (or elements) of this array? 
2. In the array 
double [] score = n...
Preview 3 out of 23 pages
Add to cart1. In the array declaration 
String[] word = new String[5]; 
what is 
a. the array name? 
b. the base type? 
c. the length of the array? 
d. the range of values an index accessing this array can have? 
e. one of the indexed variables (or elements) of this array? 
2. In the array 
double [] score = n...
Inheritance 
1. Suppose the class named DiscountSale is a derived class of a class called Sale . 
Suppose the class Sale has instance variables named price and numberOfItems . 
Will an object of the class DiscountSale also have instance variables named 
price and numberOfItems ? 
2. Suppose the clas...
Preview 2 out of 12 pages
Add to cartInheritance 
1. Suppose the class named DiscountSale is a derived class of a class called Sale . 
Suppose the class Sale has instance variables named price and numberOfItems . 
Will an object of the class DiscountSale also have instance variables named 
price and numberOfItems ? 
2. Suppose the clas...
1. Explain the difference between the terms late binding and polymorphism . 
2 . Suppose you modify the definitions of the class Sale ( Display 8.1 ) by adding the 
modifier final to the definition of the method bill . How would that change 
the output of the program in Display 8.3 ? 
3. Would it be...
Preview 2 out of 7 pages
Add to cart1. Explain the difference between the terms late binding and polymorphism . 
2 . Suppose you modify the definitions of the class Sale ( Display 8.1 ) by adding the 
modifier final to the definition of the method bill . How would that change 
the output of the program in Display 8.3 ? 
3. Would it be...
Preview 3 out of 19 pages
Add to cartjava File I/O 
1. A stream is a flow of data. From where and to where does the data flow in an input stream? From where and to where does the data flow in an output stream? 
2. What is the difference between a binary file and a text file? 
3. What kind of exception might be thrown by the following, ...
Preview 2 out of 11 pages
Add to cartjava File I/O 
1. A stream is a flow of data. From where and to where does the data flow in an input stream? From where and to where does the data flow in an output stream? 
2. What is the difference between a binary file and a text file? 
3. What kind of exception might be thrown by the following, ...
Recursion 
1. What is the output of the following program? 
public class Exercise1 
{ 
public static void main(String[] args) 
{ 
cheers(3); 
} 
public static void cheers( int n) 
{ 
if (n == 1) 
{ 
Sln("Hurray"); 
} 
else 
{ 
Sln("Hip"); 
cheers(n – 1); 
} 
} 
}
Preview 2 out of 10 pages
Add to cartRecursion 
1. What is the output of the following program? 
public class Exercise1 
{ 
public static void main(String[] args) 
{ 
cheers(3); 
} 
public static void cheers( int n) 
{ 
if (n == 1) 
{ 
Sln("Hurray"); 
} 
else 
{ 
Sln("Hip"); 
cheers(n – 1); 
} 
} 
}
Exam (elaborations) UML and Patterns in java
Preview 2 out of 10 pages
Add to cartExam (elaborations) UML and Patterns in java
1.Can you have a variable of an interface type? Can you have a parameter of an 
interface type? 
2. Can an abstract class ever implement an interface? 
3. Can a derived class have two base classes? Can it implement two interfaces? 
4. Can an interface implement another interface?
Preview 2 out of 15 pages
Add to cart1.Can you have a variable of an interface type? Can you have a parameter of an 
interface type? 
2. Can an abstract class ever implement an interface? 
3. Can a derived class have two base classes? Can it implement two interfaces? 
4. Can an interface implement another interface?
Generics and the ArrayList Class in java 
1. Suppose list is an object of the class ArrayList<String> . How do you add 
the string "Hello" to the ArrayList list ? 
2. Suppose instruction is an object of the class ArrayList<String> that contains 
the string "Stop" at index position 5 ...
Preview 2 out of 9 pages
Add to cartGenerics and the ArrayList Class in java 
1. Suppose list is an object of the class ArrayList<String> . How do you add 
the string "Hello" to the ArrayList list ? 
2. Suppose instruction is an object of the class ArrayList<String> that contains 
the string "Stop" at index position 5 ...
Linked Data Structures 
1. What output is produced by the following code? 
LinkedList1 list = new LinkedList1( ); 
ToStart("apple pie", 1); 
ToStart("hot dogs", 12); 
ToStart("mustard", 1); 
tList( );
Preview 2 out of 12 pages
Add to cartLinked Data Structures 
1. What output is produced by the following code? 
LinkedList1 list = new LinkedList1( ); 
ToStart("apple pie", 1); 
ToStart("hot dogs", 12); 
ToStart("mustard", 1); 
tList( );
1. Give the definition of a boolean valued static generic method named inSome . 
The method inSome has two parameters of type Collection<T> and one 
parameter of type T . The method returns true if the parameter of type T is in 
either (or both) collections; it returns false otherwise. 
2. Giv...
Preview 1 out of 4 pages
Add to cart1. Give the definition of a boolean valued static generic method named inSome . 
The method inSome has two parameters of type Collection<T> and one 
parameter of type T . The method returns true if the parameter of type T is in 
either (or both) collections; it returns false otherwise. 
2. Giv...
1. What Swing class do you normally use to define a window? Any window class 
that you define would normally be an object of this class.
Preview 3 out of 22 pages
Add to cart1. What Swing class do you normally use to define a window? Any window class 
that you define would normally be an object of this class.
1. Because sleep is a static method, how can it possibly know what thread it needs 
to pause? 
4. Here is some code that synchronizes thread access to a shared variable. How 
come it is not guaranteed to output 30,000 every time it is run? 
public class Counter 
{ 
private int counter; 
public Count...
Preview 2 out of 6 pages
Add to cart1. Because sleep is a static method, how can it possibly know what thread it needs 
to pause? 
4. Here is some code that synchronizes thread access to a shared variable. How 
come it is not guaranteed to output 30,000 every time it is run? 
public class Counter 
{ 
private int counter; 
public Count...
Exam (elaborations) java Applets and HTML 
1. When a browser displays text from an HTML document, where does the browser 
put the line breaks? Does it leave them where they are in the HTML document? 
Does it insert a line break after every 80 characters? Or does it do something else? 
2. What is th...
Preview 2 out of 6 pages
Add to cartExam (elaborations) java Applets and HTML 
1. When a browser displays text from an HTML document, where does the browser 
put the line breaks? Does it leave them where they are in the HTML document? 
Does it insert a line break after every 80 characters? Or does it do something else? 
2. What is th...
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Stuvia is a marketplace, so you are not buying this document from us, but from seller codersimon. Stuvia facilitates payment to the seller.
No, you only buy these notes for $27.00. You're not tied to anything after your purchase.
4.6 stars on Google & Trustpilot (+1000 reviews)
77254 documents were sold in the last 30 days
Founded in 2010, the go-to place to buy study notes for 14 years now