questions

questions





Q. 1 programes on if....else 1. write a program to check whether entered year is leap year or not 2. write a program to check whether entered no. ends with 5 or not 3. write a program to find minimum of 3 nos using nested if else. 4. write a program to check whether entered no. is divisible by 5 or 7 or both 5. write a program to input score of a student out of 100 and print grades using else .... if ladder





Q. 2 programes on switch 1. write a program to design menu driven arithmetic calculator 2. write a program to print no of days in a given month





Q. 3 programes on while loop 1. write a program to calculate sum of an entered digit 2. write a program to find gcd and lcm of 2 positive integers





Q. 4 programes on do... while 1. write a program to print reverse of a given digit 2. write a program to check whether entered digit is palindrome or not 3. write a program to check whether entered no. is Armstrong or not





Q. 5 programes on for loop a. write a program to find squares and cubes of 1st 10 integers b. write a program to to calculate factorial of a no. c. write a program to print Fibonacci series d. write a program to check whether entered no is prime or not e. write a program to print given pattern * * * * * * * * * * * * *





Q. 6 programes on array a. write a program to find max and min element in an array of an integer b. write a program to convert decimal no. to binary and back to decimal. c. write a program to do following:- i) addition of two matrices ii) subtraction of two matrices iii) multiplication of two matrices iv) find transpose of an matrix





Q. 7 programes on strings a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not





Q. 8 programes on methods 1. write a program to implement bubble sort 2. write a program to demonstrate call by value and call by reference.(pass objects as parameters) 3. write a program to calculate factorial of a no. using recursive function 4. write a program to concatenate two strings entered by user 5. design a class called cricket to store information of players. Read information of 50 players and display information w.r.t. batting

average.





Q. 9 write a program to store information of 50 products(code, quantity and price). Calculate the total cost (quantity*price) of each product

and print the information.





Q. 10 write a program to calculate volume of a cube, cylinder, rectangular box using method overloading





Q. 11 WAP to demonstrate a) static data members b) static methods

In our java programming language we have 2 types of variables those are static variables and instance variables.In the same way we have 2 types

of methods those are instance methods and static methods.

Methods and Variables in Java

In our java programming language we have 2 types of variables those are static variables and instance variables. In the same way we have 2

types of methods those are instance methods and static methods. Instance variables and methods do not preceded by the static keyword where as

static variables methods followed by the keyword static.

Instance variables

Instance data members are those whose memory space is creating each and every time when we create an object. If any data member is taking a

specific value then that data member is recommended make as instance data member that means any data member is created in a class it will

belongs to only those objects. Programmatic instance data members declaration should not followed by a keyword static.

Main points

1.Each and every instance data member must be accessed with respect to object. 2.the value of instance data member is not sharable. 3.Instance data members are also known as object level members since they depend on object name but independent from class name.

Static Data Members :

Static data members are those whose memory space is creating only once when ever the class is loaded in main memory irrespective of number of

objects are created. If any data member is taking a specific value then that data member common value for many numbers of objects then that

data member is recommended make as static variable. Programmatic static variables declaration must be preceded by a keyword static.

Main points

  1. All static data members accessed with respect to class name.
  2. the value static data member is always sharable.
  3. Static members also known as class level data member since they depend on class and independent from object.

Instance Methods

Instance methods are those which perform repeated operation such as such as reading the data form file, reading the data from data base and

etc. Programmatic if we want make any method as instance method that method can not preceded by the keyword static.

Syntax for Instance method

Return-type method-name(list of parameters if any){

// Block of statements;

}

Main points

  1. Instance methods in java must be accessed with respect to object name. Ex. object-name.sum(); 2.Instance methods are also known as object level method since they depend on object name since they depend on the object name and independent

from the class name.

Static methods

Static methods are those which are recommended to perform one time operations such as opening a file either in read or write mode, opening the

data base connection, verification of user name and password and etc. programmatic if we want make any method as static then the definition of

such method must be preceded by keyword static

Syntax for the Static method

static Return-type Method-name(list of parameters if any){

//Block of statements.

}

Main points

1.All static members in java must be accessed with respect to class name. Syntax: class-name.static-method-name();

Example: Integer.parseInt("100");

2.The result of static method is always sharable. static methods are also known as class-level methods since they depend on class.

eg

// Demonstrate static variables, methods, and blocks.
class UseStatic {
static int a = 3;
static int b;
static void meth(int x) {
System.out.println("x = " + x);
System.out.println("a = " + a);
System.out.println("b = " + b);
}
static {
System.out.println("Static block initialized.");
b = a * 4;
}
public static void main(String args[]) {
meth(42);
}
}
class StaticDemo {
static int a = 42;
static int b = 99;
static void callme() {
System.out.println("a = " + a);
}
}
class StaticByName {
public static void main(String args[]) {
StaticDemo.callme();
System.out.println("b = " + StaticDemo.b);
}
}
Here is the output of this program:
a = 42
b = 99





Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java





Q. 13 WAP to demonstrate multiple inheritance using interfaces

ANS.......

/* Area Of Rectangle and Triangle using Interface * /

interface Area { float compute(float x, float y); }

class Rectangle implements Area { public float compute(float x, float y) { return(x * y); } }

class Triangle implements Area { public float compute(float x,float y) { return(x * y/2); } }

class InterfaceArea { public static void main(String args[]) { Rectangle rect = new Rectangle(); Triangle tri = new Triangle(); Area area; area = rect; System.out.println("Area Of Rectangle = "+ area.compute(1,2));

area = tri; System.out.println("Area Of Triangle = "+ area.compute(10,2)); } } /* OUTPUT *

Area Of Rectangle = 2.0 Area Of Triangle = 10.0 */

View Answers









Related Tutorials/Questions & Answers:
servlet questions
servlet questions  pls send servlet interview questions to [email protected]
Java - Java Interview Questions
Java  Questions on Java
Advertisements
beginners questions
beginners questions  I need all the possible Java beginners questions to prepare for an Interview
interview questions - Java Interview Questions
interview questions for Java  Hi Any one can u please post the interview point of questions.Warm Regards, Satish
java questions - Java Interview Questions
java questions  HI ALL , how are all of u?? Plz send me the paths of java core questions and answers pdfs or interview questions pdfs or ebooks :) please favor me best books of interviews questions for craking
java - Java Interview Questions
Helpful Java Interview questions   Need Helpful Java Interview questions
programming questions
programming questions  this is my assignment questions please help me... the programs in c# language Describe the following with respect to creating Web Forms in .Net environment: a. Web Form Life Cycle b. Creating a Web Form
interview - Java Interview Questions
interview  kindly guide me some interview questions of Java
Hi - Hibernate Interview Questions
Hi   please send me hibernate interview questions
javascript questions on date
javascript questions on date  how to add some days to an existing date
Hibernate - Hibernate Interview Questions
hibernate interview questions and answers  Hi, Can anyone give me the best reference of hibernate interview questions and answers?Thanks in advance
JAVA QUESTIONS - Java Beginners
java questions asked in interview oracle  Hi all, Does anyone have a list of Java questions that is generally asked in Interview at Oracle
Related Questions
Related Questions  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Related Questions Try to provide me good examples or tutorials links so that I can learn the topic
questions
questions   Q. 1 programes on if....else 1. write a program... (adsbygoogle = window.adsbygoogle || []).push({}); Q. 2 programes on switch.... write a program to print no of days in a given month Q. 3 programes on while
questions
questions
questions
questions
questions
questions
questions
questions
questions
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
jvm - Java Interview Questions
jvm  Can you provide some JVM Questions for Java Interview preparation
Struts - Java Interview Questions
Struts Interview Questions  I need Java Struts Interview Questions and examples
intervw questions for an Android
intervw questions for an Android  Hi Friends, plz send me some important Q&A for an android interview
Example questions of JSP & Servlet
Example questions of JSP & Servlet  Give me some JSP & Servlet Question and their answers
Java Interview Questions
Java Interview Questions  Hi, Can anyone tell the urls of Java Interview Questions on roseindia.net? Thanks
About interview questions
About interview questions   I want interview questions on IDE's Please send links
help me - Java Interview Questions
interview questions java pdf   Do you have any PDF for Java Interview questions
Questions about Java's String pool
Questions about Java's String pool  Questions about Java's String pool
java - Servlet Interview Questions
java  servlet interview questions  Hi friend, For Servlet interview Questions visit to : http://www.roseindia.net/interviewquestions/servlet/ Thanks
multiple choice questions
multiple choice questions  how can i store 10 multiple choice questions in one class with using java language
multiple choice questions
multiple choice questions  how can i implement the program to store multiple questions in class with using core java concepts
interview questions - EJB
interview questions in Java  Need interview questions in Java  Hi,Please check the following linksJ2EE tutorial and documentations: http://www.roseindia.net/ejb/Interview Questions: http://www.roseindia.net
Interview Questions - What is JRE?
Interview Questions - What is JRE?  Hi, What is JRE? Thanks   Hi, JRE is known as Java Runtime Environment and its minimal components... and JVM? View all interview questions at Java Interview Questions with Answers
java certification questions - Java Beginners
java certification questions  i need java certification questions
questions from an xml file
questions from an xml file  i am developing online bit by bit exam for that i retrieved questions from an xml file but when i retrieved using jsp i am getting all questions at a time in a single page.but i want to show one
Interview Questions - What is JDK?
Interview Questions - What is JDK?  Hi, What is JDK? Thanks  .... Check: Beginners Java Tutorials - Installing JDK. View all interview questions at Java Interview Questions with Answers page. Thanks   Video tutorial
java - Java Interview Questions
Java Development  I need a Job in Java Development..so preparing for it. Can anyone please guide me how to prepare and what are the common questions that can be asked at interview
ModuleNotFoundError: No module named 'List-Questions'
ModuleNotFoundError: No module named 'List-Questions'  Hi, My... named 'List-Questions' How to remove the ModuleNotFoundError: No module named 'List-Questions' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'little-questions'
ModuleNotFoundError: No module named 'little-questions'  Hi, My... named 'little-questions' How to remove the ModuleNotFoundError: No module named 'little-questions' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'moodle-questions'
ModuleNotFoundError: No module named 'moodle-questions'  Hi, My... named 'moodle-questions' How to remove the ModuleNotFoundError: No module named 'moodle-questions' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'natural-questions'
ModuleNotFoundError: No module named 'natural-questions'  Hi, My... named 'natural-questions' How to remove the ModuleNotFoundError: No module named 'natural-questions' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'questions-three'
ModuleNotFoundError: No module named 'questions-three'  Hi, My... named 'questions-three' How to remove the ModuleNotFoundError: No module named 'questions-three' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'uva-questions'
ModuleNotFoundError: No module named 'uva-questions'  Hi, My... 'uva-questions' How to remove the ModuleNotFoundError: No module named 'uva-questions' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'curses-questions'
ModuleNotFoundError: No module named 'curses-questions'  Hi, My... named 'curses-questions' How to remove the ModuleNotFoundError: No module named 'curses-questions' error? Thanks   Hi, In your
Interview Questions - What is Java?
Interview Questions - What is Java?  What is Java?   Hi, Java is high level programming langue developed by James Gosling. Now Java.... Check in detail at: What is Java? View all Java Interview Questions

Ads