Java constructor is similar to the method. It calls when an object(instance) of a class is created. Allocated in the […]
Java is an Object Oriented Programming language. There are many object oriented features in java such as Inheritance, Polymorphism, Abstraction, Encapsulation etc.
The first object-oriented programming language is Simula.
Java is known as truly object-oriented programming language because all java programs is written in class.
Short Name Format Program in Java
Words in Sentence Program in Java, Enter a sentence or string and print its words of string in java.
Sentence Reverse Program in Java. Enter a sentence or string and print its reverse string in java.
A number is said to be an Ugly number if positive numbers whose prime factors only include 2, 3, 5.
For example, 6(2×3), 8(2x2x2), 15(3×5) are ugly numbers while 14(2×7) is not ugly since it includes another prime factor 7. Note that 1 is typically treated as an ugly number.
A number is said to be a pronic number if product of two consecutive integers is equal to the number, is called a pronic number.
Example- 42 is said to be a pronic number, 42=6×7, here 6 and 7 are consecutive integers
Magic number is the if the sum of its digits recursively are calculated till a single digit If the single digit is 1 then the number is a magic number. Magic number is very similar with Happy Number.
Prime Number Up to N Terms Program in Java. Ex: Enter size of prime=5
Number is prime=2
Number is prime=3
Number is prime=5
Number is prime=7
Number is prime=11
Number is prime=13
Define a class called Mobike with the following description:
Instance variables/data members:
String bno – to store the bike’s number(UP65AB1234)
String name – to store the name of the customer
int days – to store the number of days the bike is taken on rent
int charge – to calculate and store the rental charge
void input( ) – to input and store the detail of the customer.
void compute( ) – to compute the rental chargeThe rent for a mobike is charged on the following basis.
First five days Rs 500 per day;
Next five days Rs 400 per day
Rest of the days Rs 200 per day
void display ( ) – to display the details in the following format:
Bike No. PhoneNo. No. of days Charge