Login


Lost your password?

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


Shop
Java: All Recent Posts Ungrouped

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.


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.


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.


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


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.


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

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


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.


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);


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));


Output writing – indexOf, substring #7241  (15-Apr-2019)
In Topic(s) : String Class Functions   

Write the output for the following:
String s=”Today is Test” ;
System.out.println(s.indexOf(‘T’));
System.out.println(s.substring(0,7) + ” ” +”Holiday”);








Output Writing – For loop break #7226  (15-Apr-2019)
In Topic(s) : Basic Loop Types    Jumping within loops   

Give the output of the following program segment and also mention the number of times the loop is executed:

int a,b;
for (a = 6, b = 4; a <= 24; a = a + 6)
{
  if (a%b ==0)
    break;
}
System.out.println(a);




Array Filling – Name and Marks – Average and Deviation display #7198  (12-Apr-2019)
In Topic(s) : Array Basics   

Write a program to accept name and total marks of N number of students in two single subscript array name[ ] and totalmarks[ ].
Calculate and print:
(i) The average of the total marks obtained by N number of students.
[average = (sum of total marks of all the students)/N]
(ii) Deviation of each student’s total marks with the average.
[deviation = total marks of a student – average]


Patterns: ABCDE-ABCD-ABC-AB-A & B-LL-UUU-EEE #7196  (12-Apr-2019)
In Topic(s) : Pattern Printing   

Write a menu driven program to display the pattern as per user’s choice.
Pattern 1 Pattern 2
ABCDE       B
ABCD         LL
ABC            UUU
AB              EEEE
A
For an incorrect option, an appropriate error message should be displayed.


Function Overloading – Volume #7194  (12-Apr-2019)
In Topic(s) : Function overloading   

Design a class to overload a function volume() as follows:

(i) double volume (double R) ¡V with radius (R) as an argument, returns the volume of sphere using the formula.
V = 4/3 x 22/7 x R^3
(ii) double volume (double H, double R) ¡V with height(H) and radius(R) as the arguments, returns the volume of a cylinder using the formula.
V = 22/7 x R^2 x H
(iii) double volume (double L, double B, double H) ¡V with length(L), breadth(B) and Height(H) as the arguments, returns the volume of a cuboid using the formula.
V = L x B x H


Pronic Number Check #7190  (12-Apr-2019)
In Topic(s) : Specially Named Numbers   

Write a program to input a number and check and print whether it is a Pronic number or not. (Pronic number is the number which is the product of two consecutive integers)
Examples: 12 = 3 x 4
20 = 4 x 5
42 = 6 x 7


Class Design – Railway Ticket #7188  (12-Apr-2019)
In Topic(s) : Defining Classes   

Design a class RailwayTicket with following description:

Instance variables/data members :
String name : To store the name of the customer
String coach : To store the type of coach customer wants to travel
long mobno : To store customer’s mobile number
int amt : To store basic amount of ticket
int totalamt : To store the amount to be paid after updating the original amount
Member methods :
void accept () – To take input for name, coach, mobile number and amount.
void update() – To update the amount as per the coach selected
(extra amount to be added in the amount as follows)

Type of Coaches Amount
First_AC 700
Second_AC 500
Third_AC 250
sleeper None

void display() – To display all details of a customer such as name, coach, total amount and mobile number.
Write a main method to create an object of the class and call the above member methods.


B04C-2019S-C2 #7158  (11-Apr-2019)

Considering the following definition of class DOCTORS, write a method/function SPLDOCS() in python to search and display all the content from a pickled file DOCS.DAT, where Specialisation of DOCTORS is “CARDIOLOGY”.

class DOCTORS:
def __init__(self,N,S):
  self.Name=N
  self.Specialisation=S
def Disp(self):
  print self.Name, "#", self.Specialication

 


B04C-2019S-C1 #7156  (11-Apr-2019)

Considering the following definition of class STOCK, write a method/function COSTLY() in pyhton to search and display Name and Price from a pickled file STOCK.DAT, where Price of the items are more than 1000.

class Stock:
  def __init__(self, N, P):
    self.Name=N
    self.Price=P
  def Show(self) :
    print self.Name, "@", self.Price

B04B-2019S-C2 #7154  (11-Apr-2019)

Write a method/function AEDISP() in python to read lines from a text file WRITER.TXT, and display those lines, which are starting either with A or starting with E.


B04B-2019S-C1 #7152  (11-Apr-2019)

Write a method/function ISTOUPCOUNT() in python to read contents from a text file WRITER>TXT, to count and display the occurrence of the word “IS” or “TO” or “UP”.

For example:

If the content of the file is

IT IS UP TO US TO TAKE CARE OF OUR SURROUNDING. IT IS NOT POSSIBLE ONLY FOR THE GOVERNMENT TO TAKE RESPONSIBILITY

The method/function should display

Count of IS TO and UP is 6


B04A-2019S-C2 #7150  (11-Apr-2019)

Write a statement in Python to open a text file README.TXT so that existing content can be read from it.


B04A-2019S-C1 #7148  (11-Apr-2019)

Write a statement in Python to open a text file WRITEUP.TXT so that new content can be written in it .


B03E-2019S-C2 #7145  (11-Apr-2019)

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion:

A + B * C ^ D – E


B03E-2019S-C1 #7143  (11-Apr-2019)

Evalute the following Postfix expression, showing the stack contents:

 250,45,9,/,5,+,20,*,-


B03D-2019S-C2 #7141  (11-Apr-2019)

Write a python method/function Count3and7(N) to find and display the count of all those numbers which are between 1 and N,

which are either divisible by 3 or by 7.

For example :

If the value of N is 15

The sum should be displayed as 7

(as 3,6,7,9,12,14,15 in between 1 to 15 are either divisible by 3 or 7)


B03D-2019S-C1 #7139  (11-Apr-2019)

Write a python method/function Swapper(Numbers) to swap the first half of the content of a list Numbers with second half of the content Numbers and display the swapped values.

Note: Assuming that the list has even number of values in it.

For example: if the list Numbers contains

[35, 67, 89, 23, 12, 45]

After swapping the list content should be displayed as

[23, 12, 45, 35, 67, 89]


B03C-2019S-C2 #7137  (11-Apr-2019)

Write PushOn(Book) and Pop(Book) methods/functions in Python to add a new Boo and delete a Book from a List of Book titles, considering them to act as push and pop operations of the Stack data structure.


B03C-2019S-C1 #7134  (11-Apr-2019)

Write QueueUp(Client) and QueueDel(Client) methods/functions in Python to add a new Client and delete a Client from a List of Client names, considering them to act as insert and delete operations of the Queue data Structure.


B03B-2019S-C2 #7132  (11-Apr-2019)

Write definition of a method/function HowMany(ID,Val) to count and display number of times the values of Val is present in the list ID.

For Example:

If the ID contains [115, 122, 137, 110, 122, 113] and Val contains 122

The function should display

122 found 2 Times


B03B-2019S-C1 #7130  (11-Apr-2019)

Write definition of a method/function AddOddEven(VALUES) to display sum of odd and even values separately from the list of Values.

For example:

If the VALUES contain [15,26,37,10,22,13]

The function should display

Even Sum:58

Odd Sum:65


B03A-2019S-C2 #7128  (11-Apr-2019)

Consider the following randomly ordered numbers stored in a list:

106, 104, 106, 102, 105, 107

Show the content of list after the First, Second and Thired pass of the bubble sort method used for arranging in descending order.

 

 


B03A-2019S-C1 #7126  (11-Apr-2019)

Consider the following randomly ordered numbers stored in a list:
106, 104, 106, 102, 105, 10
Show the content of list after the First, Second and Third pass of the Selection sort method used for arranging in ascending order.
Note : Show the status of all the elements after each pass very clearly encircling the changes.


B02D-2019S-21 #7120  (11-Apr-2019)

Define inheritance, Show brief pyth0n example of single Level, Multiplier and m Multilevel Inheritance.


B02D-2019S-C1 #7114  (11-Apr-2019)

Answer the questions(i) to (iii) based on the following:

class Furniture(object) :             #Line 1
  def __init__(self,Q) :                   #Line 2
    self.Qty = Q 
  def GetMore(self,TQ) :                   #Line 3
    self.Qty =self.Qty+TQ
  def FRDisp(self):                        #Line 4
    print self.Qty

class Fixture(object):                     #Line 5
  def __init__(self,TQ):                   #Line 6
    self.Qty=TQ
  def GetMore (self, TQ):                  #Line 7
    self.Qty = self.Qty_TQ
  def FXDisp(self):                        #Line 8
    print self .Qty
Class Flat (Furniture, Fixture):           #Line 9
  def __init__(self, fno):                 #Line 10
    self,Fno=fno
    Q=0
    if self.Fno<100:
    Q=10
    else:
    Q=20
    Furniture.__init__(self, Q):            #Line 11
    Fixture.__init__(self,Q):               #Line 12
  def More(self,Q):                         #Line 13
    Furniture.GetMore(self,Q
    Fixture.GetMore(self,Q)
  def FLDisp(self):                         #Line 14
    print self.Fno,
    Furniture.FRDisp(Self)
    Fixture.FXDisp(self)
    Fl=FLAT(101)                            #Line 15

(i) Write the type of the inheritance illustrated in the above.
(ii) Find and write the output of the above code.
(iii) What is the difference between the statements shOwn in Line 11 and Line ?


B02C-2019S #7109  (11-Apr-2019)

Define a class House in Python with the following specifications:

Instance Attributes

-Hno              #House Number

-Nor              # Number of Rooms

-Type           # Type of the House

Methods/function

-AssignType()    # To assign Type of House

# based on Number of Rooms as follows :

 

Nor Type
<=2 LIG
==3 MIG
>3 HIG

– Enter()     # To allow user to enter value of

# Hno and Nor. Also, this method should

# call Assigntype() to assign Type

– # To display Hno, Nor and Type.


B02B-2019S-C2 #7107  (10-Apr-2019)
class Target:                    #Line 1
  def __init__(self):            #Line 2
    self.X = 20                  #Line 3
    self.Y = 20                  #Line 4
  def Disp(self):                #Line 5
    print self.X,self.Y          #Line 6
  def __del__(self):             #Line 7
     print "Target Moved"        #Line 8
def One():                       #Line 9
  T=Target()                     #Line 10
  T.Disp()                       #Line 11
One()                            #Line 12

(i) Write are the methods/functions mentioned in Line 2 and Line 7 specifically known as ?

(ii) Mention the line number of the statement, which will call and execute the method/function shown in Line 2.


B02B-2019S-C1 #7101  (10-Apr-2019)
class Box:                       #Line 1
  L=10                           #Line 2
  TYpe="HARD"                    #Line 3
  def __init__(self, T, TL=30):  #Line 4
    self.Type = T                #Line 5
    self.L  = TL                 #Line 6
  def Disp(self):                #Line 7
     print self.Type, Box.Type   #Line 8
     print self.L,Box.L          #Line 9
B1=Box("SOFT",20)                #Line 10
B1.Disp()                        #Line 11
Box.Type="FLEXI"                 #Line 12
B2=Box("HARD")                   #Line 13
B2.Disp()                        #Line 14

Write the output of the above Python code.


B02A-2019S #7098  (10-Apr-2019)

Write four features of object oriented programming.


B01F-2019S #7096  (10-Apr-2019)

What possible output(s) are expected to be displayed on screen at the time of execution of the program from the following code ? Also specify the minimum values that can be assigned to each of the variables BEGIN and LAST.

import random
VALUES=[10,20,30,40,50,60,70,80]
BEGIN=random.randint(1,3)
LAST=random.randint(BEGIN,4)

for I in range(BEGIN, LAST+1):
print VALUES[I],"-",
(1) 30 – 40 – 50 – (ii) 10 – 20 – 30 – 40 –
(iii) 30 – 40 – 50 – 60 – (iv) 30 – 40 – 50 – 60 – 70 –

: Quiz
Back