Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
Java: All Recent Posts Grouped
Concept Learning Code Sheets View all
Resolving Class and Local Variable Name Clash #3871  (20-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

Methods to rightly use variable names when their names clash between class/static types and local types.


Variable Default Values #3867  (20-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

Java class variables have default values. Let us experiment with that.


Variable Kinds – Local, Class and Instance Variables #3865  (20-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

Mainly used kinds Local, Class and Instance Variables are discussed here.


Variable Declaration and Initialisation #3862  (20-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

Variable declaration and initialisation varieties are explained here.


Understanding Reference data type #3859  (20-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

Reference data type for class object reference and array reference.


Understanding boolean data type #3850  (19-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

The java boolean data type declaration and its features.


Understanding char data type #3848  (19-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

The java char data type and its possible values are explained here.


Understanding byte, short, int and long types #3846  (19-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

Different types of integer data types with its maximum and minimum value limits are explained with this code.


Understanding double and float data type #3840  (19-Mar-2018)
In Topic(s) : Data Types Variables and Constants   

Double and float data type declaration its max value and sizing.


Boolean Literals #3822  (13-Mar-2018)
In Topic(s) : Tokens Keywords Identifiers Literals   

Use of boolean literals.


Solved ProblemsView all
String class methods to separate file path, name and extension #7428 (18-Apr-2019)
In Topic(s) : String Class Functions   

Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and
file extension separately as shown.
Input C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg

Write a program to assign a full path and file name as given below. Using lib


Floyd’s Triangle and ICSE as pattern #7319 (16-Apr-2019)
In Topic(s) : Pattern Printing   

Using the switch statement, write a menu driven program for the following:
(i) To print the Floyd’s triangle
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(ii) To display the following pattern
I
I C
I C S
I C S E
For an incorrect option, an appropriate error message should be displayed.

Using the switch statement, write a menu driven program for the following:


07A-2017 #7262 (15-Apr-2019)
In Topic(s) : Array Basics   

Write a program to input integer elements into an array of size 20 and perform the following operations:
(i) Display largest number from the array.
(ii) Display smallest number from the array.
(iii) Display sum of all the elements of the array.

Write a program to input integer elements into an array of size 20 and perfor


Series problems #7260 (15-Apr-2019)
In Topic(s) : Series Printing   

Using switch statement, write a menu driven program for the following:

(i) To find and display the sum of the series given below:
S = x1 – x2 + x3 – x4 + x5 … – x20, where x = 2.
(where x = 2)

(ii) To display the following series:
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.

Using switch statement, write a menu driven program for the following:


Spy number check #7256 (15-Apr-2019)
In Topic(s) : Specially Named Numbers   

Write a program to accept a number and check and display whether it is a spy number or not. (A number is spy if the sum of its digits equals the product of its digits.)
Example: consider the number 1124, Sum of the digits = 1 + 1 + 2 + 4 = 8
Product of the digits = 1 x 1 x 2 x 4 = 8

Write a program to accept a number and check and display whether it is a spy


Class definition – Electric Bill #7253 (15-Apr-2019)
In Topic(s) : Defining Classes   

Define a class ElectricBill with the following specifications:

class : ElectricBill
Instance variables / data member:
String n – to store the name of the customer
int units – to store the number of units consumed
double bill – to store the amount to be paid
Member methods:
void accept( ) – to accept the name of the customer and number of units consumed
void calculate( ) – to calculate the bill as per the following tariff:
Number of units Rate per unit
First 100 units Rs.2.00
Next 200 units Rs.3.00
Above 300 units Rs.5.00
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
void print ( ) – To print the details as follows:
Name of the customer: ………………………
Number of units consumed: ………………………
Bill amount: ………………………
Write a main method to create an object of the class and call the above member methods.

Define a class ElectricBill with the following specification


03J-2017 #7251 (15-Apr-2019)
In Topic(s) : Scanner Input   

What is the difference between the Scanner class functions next() and nextLine()?

What is the difference between the Scanner class functions next() and nextLin


Output writing and loop counting #7248 (15-Apr-2019)
In Topic(s) : Compound or Nested Loops   

Analyze the given program segment and answer the following questions:

for(int i=3;i<=4;i++ ) {
for(int j=2;j<i;j++ ) {
System.out.print(“” ); }
System.out.println(“WIN” ); }

(i) How many times does the inner loop execute?
(ii) Write the output of the program segment.

Analyze the given program segment and answer the following questions:


Output Writing – Using integer wrapper #7246 (15-Apr-2019)
In Topic(s) : Wrapper Classes   

Give the output of the following code:

String A =”26″, B=”100″;
String D=A+B+”200″;
int x= Integer.parseInt(A);
int y = Integer.parseInt(B);
int d = x+y;
System.out.println(“Result 1 = “+D);
System.out.println(“Result 2 = ” +d);

Give the output of the following code:

String A =”26″, B=&


Output based on Math functions #7244 (15-Apr-2019)
In Topic(s) : Math Functions   

What are the values stored in variables r1 and r2:
(i) double r1 = Math.abs(Math.min(-2.83, -5.83));
(ii) double r2 = Math.sqrt(Math.floor(16.3));

What are the values stored in variables r1 and r2:
(i) double r1 = Math


Concept Notes and ResourcesView all

Exception is a type of runtime error while execution of program which user can possibly handle (catch) and report with a suitable message or take some other planned action.   for e.g. divide by zero (Arithmetic exceptions), array out of bound (ArrayIndexOutOfBoundsException), file not found (FileNotFoundException)   Exception can be handled by using the try […]








Back