Q.1 file Stucture from c?
Answer:-
File Structure In c:
typedef struct
{
short level ;
short token ;
short bsize ;
char fd ;
unsigned flags ;
unsigned char hold ;
unsigned char *buffer ;
unsigned char * curp ;
unsigned istemp;
}FILE ;
Q2 how to change JVM memory in eclipse ?
Answer:-
Step to increase memory on jvm in eclips:
Step1: Select Run / Open Run Dialog
Step 2: select the configuration for launching your application
Step 3: Click the Arguments tab
Step 4: in the box "VM arguments" add something like "-Xmx256M" to give your application 256 MB of memory.
Q 3 Why array index start with 0? Ans:-
It starts at 0 because the index value tells the computer how far it needs to move away from the starting point in the array. If you use an array you are really only referring to the memory address of the starting point of the array. When you reference a specific value in the array, you are telling the programming language to start at the memory address of the beginning of the array and then move up the memory address as needed. So suppose a program allocates space in the memory between address numbers 1024 and 2048 and it starts at 1024 and each item in the array is 8 bytes long. Then saying arrayName[0] is the same as telling it to look at the data stored at the memory address of (1024 + (0 * 8)), or 1024. If you want the value stored at arrayName[1], then it looks at the value held at (1024 + (1*8)), which is 1032. If you wanted the value held at arrayName[10], then it would look at the data stored in the memory address of 1024 + (10 * 8), which is 1104.
Q.4 How to create header file in C? Ans:-
Create a file and save it as .h extension
e.g.
int add(int a,int b)
{
return(a+b);
}
Save as myheader.h
In another program include this header file.
e.g.
#include<stdio.h>
#include"myheader.h"
void main()
{
int no1=30,no2=40,no3;
num3=add(no1,no2);
printf("Addition is =%d",no3);
}
Q.5 What are the different approaches of programming?
Ans:-
1)Object Oriented Programming
2)Object Base Programming
3)Procedure Oriented Programming
4)Logical Programming
5)Functional Programming
6) Modular Programming
Q.6 Difference between while and for?
Ans:-
While is dynamic and it is use when condition is not fixed.
For is static and it is use when condition is fixed.
Q. 7 if we have array of integer which containing age for 10,000 people.Sort that array with optimised way. Ans:
Program:-
public class Sort
{
static int a[]=new int[120];
public static void main(String[] args)
{
int age[]={10,15,17,20,10,13,12,15,15,40};
for(int i=0;i<age.length;i++)
{
int b=age[i];
a[b]=a[b]+1;
}
for(int j=0;j<a.length;j++)
{
int r=a[j];
for(;r>0;r--)
{
System.out.println(j);
}
}
}
}
Q.8 if you have 2 dice and you have to show date from 00-31 Ans:-
Write on dice
Dice 1- 0,1,2,3,4,5
Dice 2- 0,1,2,6,7,8
for displaying 9 rotate number 6.
Parameters for switch are Integer and character.
1)Using Integer
#include<stdio.h>
void main()
{
int n;
printf("\n enter choice");
scanf("%d",&n);
switch(n)
{
case 1:
printf("\n A is greater");
break;
case 2:
printf("\n B is greater");
break;
default:
printf("\n both are same");
exit(0);
}
}
2)Using Character
#include<stdio.h>
void main()
{
char c;
printf("\n enter choice");
scanf("%c",&c);
switch(c)
{
case 'a':
printf("\n A is greater");
break;
case 'b':
printf("\n B is greater");
break;
default:
printf("\n both are same");
exit(0);
}
}
Q.9 Diffrernce between if and switch?
IF: it works under the Boolean literal whereas
SWITCH: it works under the integer/character literal
if statement is used when we have to check two condition for example
if the condition associated to if is satiafied than the statement associated with that is executed.
void main()
{
int i ;
printf ("enter the value of i");
scanf("%d",&i);
if (i==1)
{
printf("the no is one ");
}
printf("no is not one ");
}
switch:-switch is a multiconditional control statement .in this we check different conditions
in this we uses different cases if case is satisfied the statement associated to that case is executed.
void main()
{
int n;
printf("\n enter choice");
scanf("%d",&n);
switch(n)
{
case 1:
printf("\n A is greater");
break;
case 2:
printf("\n B is greater");
break;
default:
printf("\n both are same");
exit(0);
}
}
Q.10 what is use of curly bracket of if??
This is because it would not be useful code. If you have an if-statement without curly braces ({}), only the first line / statement after the if is executed. So if you only declare a local variable, it cannot be used anywhere else.
if(proceed)
{ int i= 0; // variable i can be used here
}
if (proceed)
int i; // i can not be used anywhere as it is a local variable.
Q.11 how we declare array in c/c++?
an array need to be declare so that the compiler will know what kind of an array and how large an array we want.
There are different type of array
1. one dimensional
2. multi dimensional
In our programming, we have done with the statement:
one dimensional
syntax: data type array_name[size];
e.g. int mark[30];
multi dimensional
syntax: data type array_name[size][size];
e.g int stud[5][5];
Q12)What is SingleTone Pattern?
Ans:- The singleton pattern is a design pattern that restricts the Instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. The term comes from the mathematical concept of a singleton.
Q.13)What is Cosmic Super Class?
Ans:-
The ultimate superclass Object is taken for granted if no superclass is explicitly mentioned. Because every class in Java extends Object, it is important to be familiar with the services provided by the Object class. We go over the basic ones in this chapter and refer you to later chapters or to the on-line documentation for what is not covered here.
Q.14)All Layout manager in JAVA?
Ans:-
A)Border Layout:-
Answer:-
File Structure In c:
typedef struct
{
short level ;
short token ;
short bsize ;
char fd ;
unsigned flags ;
unsigned char hold ;
unsigned char *buffer ;
unsigned char * curp ;
unsigned istemp;
}FILE ;
Q2 how to change JVM memory in eclipse ?
Answer:-
Step to increase memory on jvm in eclips:
Step1: Select Run / Open Run Dialog
Step 2: select the configuration for launching your application
Step 3: Click the Arguments tab
Step 4: in the box "VM arguments" add something like "-Xmx256M" to give your application 256 MB of memory.
Q 3 Why array index start with 0? Ans:-
It starts at 0 because the index value tells the computer how far it needs to move away from the starting point in the array. If you use an array you are really only referring to the memory address of the starting point of the array. When you reference a specific value in the array, you are telling the programming language to start at the memory address of the beginning of the array and then move up the memory address as needed. So suppose a program allocates space in the memory between address numbers 1024 and 2048 and it starts at 1024 and each item in the array is 8 bytes long. Then saying arrayName[0] is the same as telling it to look at the data stored at the memory address of (1024 + (0 * 8)), or 1024. If you want the value stored at arrayName[1], then it looks at the value held at (1024 + (1*8)), which is 1032. If you wanted the value held at arrayName[10], then it would look at the data stored in the memory address of 1024 + (10 * 8), which is 1104.
Q.4 How to create header file in C? Ans:-
Create a file and save it as .h extension
e.g.
int add(int a,int b)
{
return(a+b);
}
Save as myheader.h
In another program include this header file.
e.g.
#include<stdio.h>
#include"myheader.h"
void main()
{
int no1=30,no2=40,no3;
num3=add(no1,no2);
printf("Addition is =%d",no3);
}
Q.5 What are the different approaches of programming?
Ans:-
1)Object Oriented Programming
2)Object Base Programming
3)Procedure Oriented Programming
4)Logical Programming
5)Functional Programming
6) Modular Programming
Q.6 Difference between while and for?
Ans:-
While is dynamic and it is use when condition is not fixed.
For is static and it is use when condition is fixed.
Q. 7 if we have array of integer which containing age for 10,000 people.Sort that array with optimised way. Ans:
Program:-
public class Sort
{
static int a[]=new int[120];
public static void main(String[] args)
{
int age[]={10,15,17,20,10,13,12,15,15,40};
for(int i=0;i<age.length;i++)
{
int b=age[i];
a[b]=a[b]+1;
}
for(int j=0;j<a.length;j++)
{
int r=a[j];
for(;r>0;r--)
{
System.out.println(j);
}
}
}
}
Q.8 if you have 2 dice and you have to show date from 00-31 Ans:-
Write on dice
Dice 1- 0,1,2,3,4,5
Dice 2- 0,1,2,6,7,8
for displaying 9 rotate number 6.
Parameters for switch are Integer and character.
1)Using Integer
#include<stdio.h>
void main()
{
int n;
printf("\n enter choice");
scanf("%d",&n);
switch(n)
{
case 1:
printf("\n A is greater");
break;
case 2:
printf("\n B is greater");
break;
default:
printf("\n both are same");
exit(0);
}
}
2)Using Character
#include<stdio.h>
void main()
{
char c;
printf("\n enter choice");
scanf("%c",&c);
switch(c)
{
case 'a':
printf("\n A is greater");
break;
case 'b':
printf("\n B is greater");
break;
default:
printf("\n both are same");
exit(0);
}
}
Q.9 Diffrernce between if and switch?
IF: it works under the Boolean literal whereas
SWITCH: it works under the integer/character literal
if statement is used when we have to check two condition for example
if the condition associated to if is satiafied than the statement associated with that is executed.
void main()
{
int i ;
printf ("enter the value of i");
scanf("%d",&i);
if (i==1)
{
printf("the no is one ");
}
printf("no is not one ");
}
switch:-switch is a multiconditional control statement .in this we check different conditions
in this we uses different cases if case is satisfied the statement associated to that case is executed.
void main()
{
int n;
printf("\n enter choice");
scanf("%d",&n);
switch(n)
{
case 1:
printf("\n A is greater");
break;
case 2:
printf("\n B is greater");
break;
default:
printf("\n both are same");
exit(0);
}
}
Q.10 what is use of curly bracket of if??
This is because it would not be useful code. If you have an if-statement without curly braces ({}), only the first line / statement after the if is executed. So if you only declare a local variable, it cannot be used anywhere else.
if(proceed)
{ int i= 0; // variable i can be used here
}
if (proceed)
int i; // i can not be used anywhere as it is a local variable.
Q.11 how we declare array in c/c++?
an array need to be declare so that the compiler will know what kind of an array and how large an array we want.
There are different type of array
1. one dimensional
2. multi dimensional
In our programming, we have done with the statement:
one dimensional
syntax: data type array_name[size];
e.g. int mark[30];
multi dimensional
syntax: data type array_name[size][size];
e.g int stud[5][5];
Q12)What is SingleTone Pattern?
Ans:- The singleton pattern is a design pattern that restricts the Instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. The term comes from the mathematical concept of a singleton.
Q.13)What is Cosmic Super Class?
Ans:-
The Object class is the ultimate ancestor—every class in Java extends Object. However, you never have to write
class Employee extends Object
The ultimate superclass Object is taken for granted if no superclass is explicitly mentioned. Because every class in Java extends Object, it is important to be familiar with the services provided by the Object class. We go over the basic ones in this chapter and refer you to later chapters or to the on-line documentation for what is not covered here.
Q.14)All Layout manager in JAVA?
Ans:-
A)Border Layout:-
...//Container pane = aFrame.getContentPane()...
JButton button = new JButton("Button 1 (PAGE_START)");
pane.add(button, BorderLayout.PAGE_START);
//Make the center component big, since that's the
//typical usage of BorderLayout.
button = new JButton("Button 2 (CENTER)");
button.setPreferredSize(new Dimension(200, 100));
pane.add(button, BorderLayout.CENTER);
button = new JButton("Button 3 (LINE_START)");
pane.add(button, BorderLayout.LINE_START);
button = new JButton("Long-Named Button 4 (PAGE_END)");
pane.add(button, BorderLayout.PAGE_END);
button = new JButton("5 (LINE_END)");
pane.add(button, BorderLayout.LINE_END);
B)Box Layout:-
JScrollPane listScroller = new JScrollPane(list);
listScroller.setPreferredSize(new Dimension(250, 80));
listScroller.setAlignmentX(LEFT_ALIGNMENT);
...
//Lay out the label and scroll pane from top to bottom.
JPanel listPane = new JPanel();
listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
JLabel label = new JLabel(labelText);
...
listPane.add(label);
listPane.add(Box.createRigidArea(new Dimension(0,5)));
listPane.add(listScroller);
listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
//Lay out the buttons from left to right.
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(cancelButton);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(setButton);
//Put everything together, using the content pane's BorderLayout.
Container contentPane = getContentPane();
contentPane.add(listPane, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.PAGE_END);
C)Card Layout:-
//Where instance variables are declared: JPanel cards; final static String BUTTONPANEL = "Card with JButtons"; final static String TEXTPANEL = "Card with JTextField"; //Where the components controlled by the CardLayout are initialized: //Create the "cards". JPanel card1 = new JPanel(); ... JPanel card2 = new JPanel(); ... //Create the panel that contains the "cards". cards = new JPanel(new CardLayout()); cards.add(card1, BUTTONPANEL); cards.add(card2, TEXTPANEL);
No comments:
Post a Comment