0% found this document useful (0 votes)
7 views

Class ZeroException Extends Exception

Uploaded by

demoacc5043
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Class ZeroException Extends Exception

Uploaded by

demoacc5043
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

class ZeroException extends Exception {

public ZeroException(String mess){

super(mess);

class Main {

public static int cal(int numb){

int lastInt=numb%10;

int firstInt=Integer.parseInt(Integer.toString(numb).substring(0,1));

return lastInt+firstInt;

public static void main(String[] args) {

int num=12;

try{

if (num==0){

throw new ZeroException("number is zero");

int sum=cal(num);

System.out.println(sum);

}catch(ZeroException e){

System.out.println("error");

finally{

System.out.println("final");

}
class Main {

public static boolean isPrime(int num){

if (num<=1){

return false;

for(int i=2;i<num;i++){

if(num%i==0){

return false;

return true;

public static void main(String[] args) {

int num=3;

if(isPrime(num)){

System.out.println("p");

else{

System.out.println("n P");

interface shap{

double area();

class Tr implements shap{

private double base;

private double height;


public Tr(double base, double height){

this.base=base;

this.height=height;

@Override

public double area(){

return (0.5 * base * height);

class Main {

public static void main(String[] args) {

Tr traingle =new Tr(10,3);

System.out.println("area"+traingle.area());

class Main {

public static void main(String[] args) {

String name = "abhishel";

int vC = countV(name);

System.out.println(vC);

public static int countV(String str) {

int count = 0;

str = str.toLowerCase();
for (int i = 0; i < str.length(); i++) {

char ch = str.charAt(i);

if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {

count++;

return count;

You might also like