Question

QUESTION 6: Advanced Java Programming John is an inexperienced programmer who doesnt understand the difference between Asser

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Assertions are intended to be used as a way of identifying programming errors or bugs - they are used for internal logic checks. Exception are for error or exceptional condition (like invalid input, network issues, etc) which may not be under the control of your program or code.

Assertions can be enabled/disabled globally or class wise and it is usually considered a good practice to remove them out of production code if logical validation is done. Exception however are meant to be kept in production code to handle conditions which are not under our control.

Examples:

Assertions can be used to check if two variables are same or not:

asset a!=b;

If a is not equal to b, assertion fails.

Exception can be thrown if the array index i goes beyond the array length l:

If( i>=l)

{throw new Exception("Index Out Of Bounds");}

Add a comment
Know the answer?
Add Answer to:
QUESTION 6: Advanced Java Programming John is an inexperienced programmer who doesn't understand the difference between...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 2: Elementary Java Programming (a) Explain what a Wrapper class is in Java and provide...

    QUESTION 2: Elementary Java Programming (a) Explain what a Wrapper class is in Java and provide an example of one and what it [06] "wraps". (b) You have been given an array of elements to search through for a particular value. [02] Which loop would you choose between a for loop and a for-each loop and why? (c) In Java what is the difference between a StringBuilder and StringBuffer? What [02] are they used for? Total: 10

  • Advanced Object-Oriented Programming using Java Assignment 4: Exception Handling and Testing in Java Introduction -  This assignment...

    Advanced Object-Oriented Programming using Java Assignment 4: Exception Handling and Testing in Java Introduction -  This assignment is meant to introduce you to design and implementation of exceptions in an object-oriented language. It will also give you experience in testing an object-oriented support class. You will be designing and implementing a version of the game Nim. Specifically, you will design and implement a NimGame support class that stores all actual information about the state of the game, and detects and throws...

  • what's the difference between overhead rate and charge? Question 2 Nadia, JOhn, Saba and Kumar are working together...

    what's the difference between overhead rate and charge? Question 2 Nadia, JOhn, Saba and Kumar are working together on a project. These are the data for each: Answer saved Nadia: 60 hours, overhead rate 75%, personal time 1096, $41/hr JOhn: 80 hours, overhead rate 55%, personal time 1296, $31/hr Saba: 80 hours, overhead rate 75%, personal time 1096, $26/hr Kumar: 40 hours, overhead rate 55%, personal time 1296, S36/hr Marked out of 1.00 Flag question Who has the highest direct...

  • -------------------------------------------------------------------- 1. How does Java support the concept of encapsulation? -------------------------------------------------------------------- 2. Describe the difference between...

    -------------------------------------------------------------------- 1. How does Java support the concept of encapsulation? -------------------------------------------------------------------- 2. Describe the difference between an object and a class. -------------------------------------------------------------------- 3. What is the difference between the contents of a Java variable of a primitive type and a Java variable of a class type? -------------------------------------------------------------------- 4. (a) How is a 'static' class method different from a regular (non-static) class method? (b) How is a 'static' variable in a class different from a regular (instance) variable in a class?...

  • CIT 149 Java 1 programming question Use DrJava to compile the following try-catch program ? The...

    CIT 149 Java 1 programming question Use DrJava to compile the following try-catch program ? The Assignment ? Specifications General Structure your file name and class name on the following pattern: The first three letters of your last name (begin with upper case.). Then the first two letters of your first name (begin with upper case.). Follow this with the name of the program: TryCatch. For a student called ’John Doe,’ the class name and file name would be: DoeJoTryCatch...

  • Programming Assignment Objective Write a Java program that utilizes multiple classes. Write a Java program that...

    Programming Assignment Objective Write a Java program that utilizes multiple classes. Write a Java program that utilizes inheritance in a practical manner. Problem: Quiz Bowl Your high school quiz bowl team has been losing its edge and needs to find a method to improve. Knowing that you are a savvy programmer, your coach asks you to write a program that the team members can use to hone their skills. Quiz Bowl questions come in three varieties: True/False Multiple Choice (variable...

  • Programming Assignment 1 Data structure Java Implement Shellsort for a linked list, based on a variant...

    Programming Assignment 1 Data structure Java Implement Shellsort for a linked list, based on a variant of bubble sort. The rather severe constraints imposed by the singly-linked list organization presents special problems for implementing Shellsort. Your task is to overcome these constraints and develop a simple, elegant implementation that does not sacrifice efficiency or waste space. Step 1. First, implement a routine to build a list: read integers from standard input, and build a list node for each item consisting...

  • Java Programming Lab 07 coding /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in th...

    Java Programming Lab 07 coding /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package lab07; /** * * @author ckandjimi */ public class Lab07 { /** * @param args the command line arguments */ public static void main(String[] args) { int outcome = methodX(5); System.out.printf("Result from Method X= %d",outcome); String [] studentNames = {"Kingston","John","Nangula","Daniela"}; int Test01[]...

  • Question 1 Most cultures recognize the difference between prescribed medications and over-the-counter medications including herbs. True...

    Question 1 Most cultures recognize the difference between prescribed medications and over-the-counter medications including herbs. True False Question 2 Where is the most reliable location to assess for petechiae in a person with darkly pigmented skin? Soles of the feet Upper chest and shoulders Lining of the mouth Palms of the hands Question 3 options: Is the following statement true or false? Subjective data refers to things that people say or relate about themselves, whereas objective data result from the...

  • Project overview: Create a java graphics program that displays an order menu and bill from a...

    Project overview: Create a java graphics program that displays an order menu and bill from a Sandwich shop, or any other establishment you prefer. In this program the design is left up to the programmer however good object oriented design is required. Below are two images that should be used to assist in development of your program. Items are selected on the Order Calculator and the Message window that displays the Subtotal, Tax and Total is displayed when the Calculate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT