Tag Archives: count

Interview Question & Answer – 7

By | October 5, 2018

Question Write a recursive program to count the number of “a”s in a string. Solution [java] package com.test; public class CountAs { static int countA(String str) { if (str.length() == 0) { return 0; } int count = 0; if (str.substring(0, 1).equals("a")) { count = 1; } return count + countA(str.substring(1)); } public static void main(String[] args) {… Read More »

HTML events in Angular JS

By | August 25, 2017

You can add AngularJS event listeners to your HTML elements by using one or more of these directives: ng-blur ng-change ng-click ng-copy ng-cut ng-dblclick ng-focus ng-keydown ng-keypress ng-keyup ng-mousedown ng-mouseenter ng-mouseleave ng-mousemove ng-mouseover ng-mouseup ng-paste Example [html] < !DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head><head> <title>Angular JS Controller</title> <script… Read More »

Shell Script to find the count of words in a file with no Vowels.

By | July 9, 2016

Below is the sample program that displays the count of words from a file that doesn’t contain any vowel in it. First create a script file using terminal. Open terminal and go to your desired folder and type in the command line. vi my_script This will create a script file named “my_script” in your current directory and it… Read More »