JAVA MTA Exam Questions With Correct
Answers
What |is |the |order |of |precedence? |- |CORRECT |ANSWER✔✔-PEMDAS
int |amount |= |30,000
double |rate |= |.10
int |licensing |= |1,000
double |total= |amount+licensing*rate
print(total)
The |output |is |30,100, |but |should |be |33,100, |how |do |you |fix |this? |- |CORRECT |ANSWER✔✔-
(amount+licensing)*rate+amount
How |do |you |print |to |user? |- |CORRECT |ANSWER✔✔-system.out.print("");
What |is |%? |- |CORRECT |ANSWER✔✔-modulus
What |does |modulus |do? |(%) |- |CORRECT |ANSWER✔✔-returns |remainder |after |division
How |do |you |create |a |scanner? |- |CORRECT |ANSWER✔✔-Scanner |in |= |new |Scanner(System.in);
What |does |next() |do? |- |CORRECT |ANSWER✔✔-returns |the |scanner |value |on |the |next |line
What |is |an |InputMismatchException? |- |CORRECT |ANSWER✔✔-when |the |the |input |data |type |is
|incorrect |or |out |of |range
, What |is |getMessage? |- |CORRECT |ANSWER✔✔-displays |details |of |an |exception
What |is |IO |Exception? |- |CORRECT |ANSWER✔✔-occurs |when |a |file |being |read |from |doesn't |
exist
What |are |the |two |types |of |exceptions? |- |CORRECT |ANSWER✔✔-checked |and |unchecked?
What |are |checked |exceptions? |- |CORRECT |ANSWER✔✔-a |type |that |is |checked |at |compile |time
What |are |unchecked |exceptions? |- |CORRECT |ANSWER✔✔-it |is |not |checked |in |compile |time
What |does |getStackTrace |do? |- |CORRECT |ANSWER✔✔-returns |an |array |of |stack |trace |
elements
What |type |of |exception |do |you |throw |for: |String |string; |string.nextInt()? |- |CORRECT |
ANSWER✔✔-An |InputMismatchException |because |it's |a |nextInt() |that |reads |a |string
What |does |Illegal |Argument |Exception |do? |- |CORRECT |ANSWER✔✔-when |an |illegal |or |
inappropriate |argument |has |been |attempted |to |be |passed |through |a |method
How |do |you |instantiate |a |new |Shirt |object? |- |CORRECT |ANSWER✔✔-Shirt |shirt |= |new |
Shirt("","","");
What |does |the |&& |operator |do? |- |CORRECT |ANSWER✔✔-tests |if |both |conditions |are |true
What |does |the ||| |operator |do? |- |CORRECT |ANSWER✔✔-test |if |one |or |the |other |condition |is |
true
Answers
What |is |the |order |of |precedence? |- |CORRECT |ANSWER✔✔-PEMDAS
int |amount |= |30,000
double |rate |= |.10
int |licensing |= |1,000
double |total= |amount+licensing*rate
print(total)
The |output |is |30,100, |but |should |be |33,100, |how |do |you |fix |this? |- |CORRECT |ANSWER✔✔-
(amount+licensing)*rate+amount
How |do |you |print |to |user? |- |CORRECT |ANSWER✔✔-system.out.print("");
What |is |%? |- |CORRECT |ANSWER✔✔-modulus
What |does |modulus |do? |(%) |- |CORRECT |ANSWER✔✔-returns |remainder |after |division
How |do |you |create |a |scanner? |- |CORRECT |ANSWER✔✔-Scanner |in |= |new |Scanner(System.in);
What |does |next() |do? |- |CORRECT |ANSWER✔✔-returns |the |scanner |value |on |the |next |line
What |is |an |InputMismatchException? |- |CORRECT |ANSWER✔✔-when |the |the |input |data |type |is
|incorrect |or |out |of |range
, What |is |getMessage? |- |CORRECT |ANSWER✔✔-displays |details |of |an |exception
What |is |IO |Exception? |- |CORRECT |ANSWER✔✔-occurs |when |a |file |being |read |from |doesn't |
exist
What |are |the |two |types |of |exceptions? |- |CORRECT |ANSWER✔✔-checked |and |unchecked?
What |are |checked |exceptions? |- |CORRECT |ANSWER✔✔-a |type |that |is |checked |at |compile |time
What |are |unchecked |exceptions? |- |CORRECT |ANSWER✔✔-it |is |not |checked |in |compile |time
What |does |getStackTrace |do? |- |CORRECT |ANSWER✔✔-returns |an |array |of |stack |trace |
elements
What |type |of |exception |do |you |throw |for: |String |string; |string.nextInt()? |- |CORRECT |
ANSWER✔✔-An |InputMismatchException |because |it's |a |nextInt() |that |reads |a |string
What |does |Illegal |Argument |Exception |do? |- |CORRECT |ANSWER✔✔-when |an |illegal |or |
inappropriate |argument |has |been |attempted |to |be |passed |through |a |method
How |do |you |instantiate |a |new |Shirt |object? |- |CORRECT |ANSWER✔✔-Shirt |shirt |= |new |
Shirt("","","");
What |does |the |&& |operator |do? |- |CORRECT |ANSWER✔✔-tests |if |both |conditions |are |true
What |does |the ||| |operator |do? |- |CORRECT |ANSWER✔✔-test |if |one |or |the |other |condition |is |
true